* Set up JS project * Finalise JS library * Update README * Fix package.json repository url * Rename package -> `kokoro-js` * Fix samples in README * Cleanup README * Bump `phonemizer` version * Create web demo * Run prettier * Link to model used in demo * Enable multithreading in HF space demo (~40% faster) * Add link to demo in README * Bump to v1.0.1 * Update voices * Update versions * Update phonemize JSDoc * Use updated voice pack * Update versions * Update demo (v1.0 & WebGPU support) * Update README * Enforce maximum number of tokens * Update README * [version] Update to 1.1.1
82 lines
4.6 KiB
Markdown
82 lines
4.6 KiB
Markdown
# Kokoro TTS
|
|
|
|
<p align="center">
|
|
<a href="https://www.npmjs.com/package/kokoro-js"><img alt="NPM" src="https://img.shields.io/npm/v/kokoro-js"></a>
|
|
<a href="https://www.npmjs.com/package/kokoro-js"><img alt="NPM Downloads" src="https://img.shields.io/npm/dw/kokoro-js"></a>
|
|
<a href="https://www.jsdelivr.com/package/npm/kokoro-js"><img alt="jsDelivr Hits" src="https://img.shields.io/jsdelivr/npm/hw/kokoro-js"></a>
|
|
<a href="https://github.com/hexgrad/kokoro/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/hexgrad/kokoro?color=blue"></a>
|
|
<a href="https://huggingface.co/spaces/webml-community/kokoro-webgpu"><img alt="Demo" src="https://img.shields.io/badge/Hugging_Face-demo-green"></a>
|
|
</p>
|
|
|
|
Kokoro is a frontier TTS model for its size of 82 million parameters (text in/audio out). This JavaScript library allows the model to be run 100% locally in the browser thanks to [🤗 Transformers.js](https://huggingface.co/docs/transformers.js). Try it out using our [online demo](https://huggingface.co/spaces/webml-community/kokoro-webgpu)!
|
|
|
|
## Usage
|
|
|
|
First, install the `kokoro-js` library from [NPM](https://npmjs.com/package/kokoro-js) using:
|
|
|
|
```bash
|
|
npm i kokoro-js
|
|
```
|
|
|
|
You can then generate speech as follows:
|
|
|
|
```js
|
|
import { KokoroTTS } from "kokoro-js";
|
|
|
|
const model_id = "onnx-community/Kokoro-82M-v1.0-ONNX";
|
|
const tts = await KokoroTTS.from_pretrained(model_id, {
|
|
dtype: "q8", // Options: "fp32", "fp16", "q8", "q4", "q4f16"
|
|
device: "wasm", // Options: "wasm", "webgpu" (web) or "cpu" (node). If using "webgpu", we recommend using dtype="fp32".
|
|
});
|
|
|
|
const text = "Life is like a box of chocolates. You never know what you're gonna get.";
|
|
const audio = await tts.generate(text, {
|
|
// Use `tts.list_voices()` to list all available voices
|
|
voice: "af_heart",
|
|
});
|
|
audio.save("audio.wav");
|
|
```
|
|
|
|
## Voices/Samples
|
|
|
|
> [!TIP]
|
|
> You can find samples for each of the voices in the [model card](https://huggingface.co/onnx-community/Kokoro-82M-v1.0-ONNX#samples) on Hugging Face.
|
|
|
|
### American English
|
|
|
|
| Name | Traits | Target Quality | Training Duration | Overall Grade |
|
|
| ------------ | ------ | -------------- | ----------------- | ------------- |
|
|
| **af_heart** | 🚺❤️ | | | **A** |
|
|
| af_alloy | 🚺 | B | MM minutes | C |
|
|
| af_aoede | 🚺 | B | H hours | C+ |
|
|
| af_bella | 🚺🔥 | **A** | **HH hours** | **A-** |
|
|
| af_jessica | 🚺 | C | MM minutes | D |
|
|
| af_kore | 🚺 | B | H hours | C+ |
|
|
| af_nicole | 🚺🎧 | B | **HH hours** | B- |
|
|
| af_nova | 🚺 | B | MM minutes | C |
|
|
| af_river | 🚺 | C | MM minutes | D |
|
|
| af_sarah | 🚺 | B | H hours | C+ |
|
|
| af_sky | 🚺 | B | _M minutes_ 🤏 | C- |
|
|
| am_adam | 🚹 | D | H hours | F+ |
|
|
| am_echo | 🚹 | C | MM minutes | D |
|
|
| am_eric | 🚹 | C | MM minutes | D |
|
|
| am_fenrir | 🚹 | B | H hours | C+ |
|
|
| am_liam | 🚹 | C | MM minutes | D |
|
|
| am_michael | 🚹 | B | H hours | C+ |
|
|
| am_onyx | 🚹 | C | MM minutes | D |
|
|
| am_puck | 🚹 | B | H hours | C+ |
|
|
| am_santa | 🚹 | C | _M minutes_ 🤏 | D- |
|
|
|
|
### British English
|
|
|
|
| Name | Traits | Target Quality | Training Duration | Overall Grade |
|
|
| ----------- | ------ | -------------- | ----------------- | ------------- |
|
|
| bf_alice | 🚺 | C | MM minutes | D |
|
|
| bf_emma | 🚺 | B | **HH hours** | B- |
|
|
| bf_isabella | 🚺 | B | MM minutes | C |
|
|
| bf_lily | 🚺 | C | MM minutes | D |
|
|
| bm_daniel | 🚹 | C | MM minutes | D |
|
|
| bm_fable | 🚹 | B | MM minutes | C |
|
|
| bm_george | 🚹 | B | MM minutes | C |
|
|
| bm_lewis | 🚹 | C | H hours | D+ |
|