@@ -24,15 +24,17 @@ Kokoro is a multilingual TTS model that supports various languages and voice sty
2424#### Example Usage
2525
2626``` python
27- from tts.models.kokoro import KokoroModel, KokoroPipeline
27+ from mlx_audio.tts.models.kokoro import KokoroPipeline
28+ from mlx_audio.tts.utils import load_model
2829from IPython.display import Audio
2930import soundfile as sf
3031
3132# Initialize the model
32- model = KokoroModel(repo_id = ' prince-canuma/Kokoro-82M' )
33+ model_id = ' prince-canuma/Kokoro-82M'
34+ model = load_model(model_id)
3335
3436# Create a pipeline with American English
35- pipeline = KokoroPipeline(lang_code = ' a' , model = model)
37+ pipeline = KokoroPipeline(lang_code = ' a' , model = model, repo_id = model_id )
3638
3739# Generate audio
3840text = " The MLX King lives. Let him cook!"
@@ -58,16 +60,17 @@ for _, _, audio in pipeline(text, voice='af_heart', speed=1, split_pattern=r'\n+
5860You can quantize models for improved performance:
5961
6062``` python
61- from tts.models.kokoro import KokoroModel
62- from tts.utils import quantize_model
63+ from mlx_audio.tts.utils import quantize_model, load_model
6364import json
6465import mlx.core as mx
6566
66- model = KokoroModel (repo_id = ' prince-canuma/Kokoro-82M' )
67+ model = load_model (repo_id = ' prince-canuma/Kokoro-82M' )
6768config = model.config
6869
6970# Quantize to 8-bit
70- weights, config = quantize_model(model, config, 64 , 8 )
71+ group_size = 64
72+ bits = 8
73+ weights, config = quantize_model(model, config, group_size, bits)
7174
7275# Save quantized model
7376with open (' ./8bit/config.json' , ' w' ) as f:
0 commit comments