diff --git a/kokoro.js/.gitignore b/kokoro.js/.gitignore new file mode 100644 index 0000000..76da710 --- /dev/null +++ b/kokoro.js/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +dist +types +LICENSE diff --git a/kokoro.js/.prettierignore b/kokoro.js/.prettierignore new file mode 100644 index 0000000..7998256 --- /dev/null +++ b/kokoro.js/.prettierignore @@ -0,0 +1,2 @@ +dist +types diff --git a/kokoro.js/README.md b/kokoro.js/README.md new file mode 100644 index 0000000..61a76ab --- /dev/null +++ b/kokoro.js/README.md @@ -0,0 +1,55 @@ +# Kokoro TTS + +

+ NPM + NPM Downloads + jsDelivr Hits + License + Demo +

+ +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-web)! + +## 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-ONNX"; +const tts = await KokoroTTS.from_pretrained(model_id, { + dtype: "q8", // Options: "fp32", "fp16", "q8", "q4", "q4f16" +}); + +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_bella", +}); +audio.save("audio.wav"); +``` + +## Voices/Samples + +> Life is like a box of chocolates. You never know what you're gonna get. + +| Voice | Nationality | Gender | Sample | +| ------------------------ | ----------- | ------ | -------------------------------------------------------------------------------------------------------- | +| Default (`af`) | American | Female |