Download Kokoro v1.0 model files
mainTo use version 1.0 of the models, you must manually download the following files and place them in your working directory:
kokoro-v1.0.onnxvoices-v1.0.bin
repository·main·Indexed 25 days ago
https://github.com/thewh1teagle/kokoro-onnxA lightweight, high-performance Text-to-Speech (TTS) library based on Kokoro-TTS that utilizes the ONNX runtime. It supports multiple languages and voices, offering near real-time performance on hardware such as macOS M1. The library provides the Kokoro class for audio generation via create() and create_stream(), as well as a Tokenizer for processing text into phonemes using espeak-ng.
To use version 1.0 of the models, you must manually download the following files and place them in your working directory:
kokoro-v1.0.onnxvoices-v1.0.binInstall the kokoro-onnx package using pip to get started with ONNX-based Text-to-Speech.
pip install -U kokoro-onnxTo build and publish a new version of the package, clear the existing dist directory, build the package using uv build, and then publish using uv publish with a PyPI token.
rm -rf dist
uv build
UV_PUBLISH_TOKEN="pypi token here" uv publishFor an isolated Python environment, use uv to manage the project and dependencies. Follow these steps:
uv:pip install uv2. Initialize a new project with Python 3.12:
```console
uv init -p 3.12uv add kokoro-onnx soundfile4. Download the required model files (`kokoro-v1.0.onnx` and `voices-v1.0.bin`) and place them in your project directory.
5. Run your script using `uv run`.
```console
uv init -p 3.12
uv add kokoro-onnx soundfile
uv run hello.pyUse ruff via uv run to format the codebase and check for linting errors.
uv run ruff format
uv run ruff checkYou can enable debug-level logging by setting the LOG_LEVEL environment variable to DEBUG when running the main script.
LOG_LEVEL=DEBUG python main.pyEspeakConfig object to specify paths for the Espeak library and data files. This is useful if Espeak is installed in a non-standard location.Tokenizer cannot find the espeak-ng shared library automatically, you can specify the exact path to the library using the PHONEMIZER_ESPEAK_LIBRARY environment variable.The project supports multiple languages and multiple voices. For a complete list of the latest available voices and supported languages, refer to the Kokoro-82M/VOICES.md documentation.
Note: It is recommended to use the misaki g2p package for version 1.0 workflows.
If you encounter a FileNotFoundError during initialization, ensure your paths are correct. If files are missing, you can download them using the following resources:
voices-v1.0.bin using:
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/voices-v1.0.binThe Tokenizer class processes text input for the TTS engine. You can initialize it with an optional EspeakConfig object to specify paths for the espeak-ng library and data, or a custom vocab dictionary.
If no configuration is provided, it attempts to locate the espeak-ng library automatically. You can also control the library path by setting the PHONEMIZER_ESPEAK_LIBRARY environment variable.
For low-latency applications, use create_stream to asynchronously yield audio chunks as they are processed. This method runs the heavy computation in a background thread to avoid blocking the event loop.
Parameters:
Same as create().
Returns:
AsyncGenerator yielding (audio_numpy_array, sample_rate) tuples.