-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathwith_espeak_lib.py
27 lines (21 loc) · 854 Bytes
/
with_espeak_lib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
Note: on Linux you need to run this as well: apt-get install portaudio19-dev
pip install kokoro-onnx sounddevice
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.onnx
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.bin
PHONEMIZER_ESPEAK_LIBRARY="/usr/local/Cellar/espeak-ng/1.52.0/lib/libespeak-ng.1.dylib" python examples/with_espeak_lib.py
"""
import os
import sounddevice as sd
from kokoro_onnx import Kokoro, EspeakConfig
kokoro = Kokoro(
"kokoro-v0_19.onnx",
"voices.bin",
espeak_config=EspeakConfig(lib_path=os.getenv("PHONEMIZER_ESPEAK_LIBRARY")),
)
samples, sample_rate = kokoro.create(
"Hello. This audio generated by kokoro!", voice="af_sarah", speed=1.0, lang="en-us"
)
print("Playing audio...")
sd.play(samples, sample_rate)
sd.wait()