-
-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathwith_quant.py
30 lines (26 loc) · 984 Bytes
/
with_quant.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
28
29
30
"""
**Smaller models should have lower quality but show no significant quality loss in checks.
Usage:
1. Install dependencies:
sudo apt-get install portaudio19-dev
pip install kokoro-onnx sounddevice
2. Download a model (choose one):
- INT8 (88MB):
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.int8.onnx
- FP16 (169MB):
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.fp16.onnx
3. Download voices.bin:
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.bin
4. Run example:
python examples/with_quant.py <chosen_model>
"""
import sounddevice as sd
from kokoro_onnx import Kokoro
import sys
kokoro = Kokoro(sys.argv[1], "voices.bin")
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()