Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ m = KittenTTS("KittenML/kitten-tts-mini-0.8", backend="cuda")

Check out `example_cuda.py`

### Using the system espeak-ng

By default, KittenTTS uses the espeak-ng library bundled with `espeakng_loader`. If you already have espeak-ng installed on your system and prefer to use it, point KittenTTS to it via the standard phonemizer environment variables before importing:

```bash
export PHONEMIZER_ESPEAK_LIBRARY=/usr/lib/libespeak-ng.so # path to your espeak-ng shared library
export ESPEAK_DATA_PATH=/usr/share/espeak-ng-data # optional: path to your espeak-ng data
```

When `PHONEMIZER_ESPEAK_LIBRARY` is set, the bundled library is not loaded and `espeakng_loader` does not need to be installed.

## API Reference

### `KittenTTS(model_name, cache_dir=None)`
Expand Down
20 changes: 17 additions & 3 deletions kittentts/onnx_model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import os
import espeakng_loader

try:
import espeakng_loader
except ImportError:
espeakng_loader = None

from phonemizer.backend.espeak.wrapper import EspeakWrapper
EspeakWrapper.set_library(espeakng_loader.get_library_path())
os.environ['ESPEAK_DATA_PATH'] = espeakng_loader.get_data_path()

# Use the system espeak-ng if the user points to it via the standard
# PHONEMIZER_ESPEAK_LIBRARY / ESPEAK_DATA_PATH environment variables,
# otherwise fall back to the library bundled with espeakng_loader.
if os.environ.get('PHONEMIZER_ESPEAK_LIBRARY'):
EspeakWrapper.set_library(os.environ['PHONEMIZER_ESPEAK_LIBRARY'])
elif espeakng_loader is not None:
EspeakWrapper.set_library(espeakng_loader.get_library_path())

if espeakng_loader is not None:
os.environ.setdefault('ESPEAK_DATA_PATH', espeakng_loader.get_data_path())
import numpy as np
import phonemizer
import soundfile as sf
Expand Down