examples.tts_multilingual¶
Multilingual TTS Example - Text to Speech with multiple models and languages Supported Models: - Kokoro: Fast, 82M params, 8 languages (en, es, fr, ja, zh, hi, it, pt) - Chatterbox: Expressive, voice cloning, 15+ languages - VibeVoice: Realtime, low latency, English - VoxCPM: High quality, Chinese/English - OuteTTS: Voice cloning, en/zh/ja/ko - Spark: Voice cloning, en/zh Usage: python examples/tts_multilingual.py "Hello world" python examples/tts_multilingual.py "Hola mundo" --lang es python examples/tts_multilingual.py "Bonjour le monde" --lang fr --model kokoro python examples/tts_multilingual.py --list-models python examples/tts_multilingual.py --list-languages
View the complete module source at #L1-L340.
API details¶
Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.
examples.tts_multilingual
¶
Multilingual TTS Example - Text to Speech with multiple models and languages
Supported Models
- Kokoro: Fast, 82M params, 8 languages (en, es, fr, ja, zh, hi, it, pt)
- Chatterbox: Expressive, voice cloning, 15+ languages
- VibeVoice: Realtime, low latency, English
- VoxCPM: High quality, Chinese/English
- OuteTTS: Voice cloning, en/zh/ja/ko
- Spark: Voice cloning, en/zh
Usage
python examples/tts_multilingual.py "Hello world" python examples/tts_multilingual.py "Hola mundo" --lang es python examples/tts_multilingual.py "Bonjour le monde" --lang fr --model kokoro python examples/tts_multilingual.py --list-models python examples/tts_multilingual.py --list-languages
examples.tts_multilingual.MODELS
module-attribute
¶
MODELS = {'kokoro': {'path': 'mlx-community/Kokoro-82M-bf16', 'family': 'kokoro', 'languages': ['en', 'es', 'fr', 'ja', 'zh', 'hi', 'it', 'pt'], 'voices': ['af_heart', 'af_bella', 'af_nicole', 'af_sarah', 'af_sky', 'am_adam', 'am_michael', 'bf_emma', 'bf_isabella', 'bm_george', 'bm_lewis'], 'default_voice': 'af_heart', 'description': 'Fast, lightweight (82M), 8 languages'}, 'kokoro-4bit': {'path': 'mlx-community/Kokoro-82M-4bit', 'family': 'kokoro', 'languages': ['en', 'es', 'fr', 'ja', 'zh', 'hi', 'it', 'pt'], 'voices': ['af_heart', 'af_bella', 'af_nicole', 'af_sarah', 'af_sky', 'am_adam', 'am_michael', 'bf_emma', 'bf_isabella', 'bm_george', 'bm_lewis'], 'default_voice': 'af_heart', 'description': 'Quantized, lower memory'}, 'chatterbox': {'path': 'mlx-community/chatterbox-turbo-fp16', 'family': 'chatterbox', 'languages': ['en', 'es', 'fr', 'de', 'it', 'pt', 'ru', 'ja', 'zh', 'ko', 'ar', 'hi', 'nl', 'pl', 'tr'], 'voices': ['default'], 'default_voice': 'default', 'description': 'Expressive, 15+ languages, voice cloning capable'}, 'chatterbox-4bit': {'path': 'mlx-community/chatterbox-turbo-4bit', 'family': 'chatterbox', 'languages': ['en', 'es', 'fr', 'de', 'it', 'pt', 'ru', 'ja', 'zh', 'ko', 'ar', 'hi', 'nl', 'pl', 'tr'], 'voices': ['default'], 'default_voice': 'default', 'description': 'Quantized chatterbox'}, 'vibevoice': {'path': 'mlx-community/VibeVoice-Realtime-0.5B-4bit', 'family': 'vibevoice', 'languages': ['en'], 'voices': ['default'], 'default_voice': 'default', 'description': 'Realtime, low latency, English only'}, 'voxcpm': {'path': 'mlx-community/VoxCPM1.5', 'family': 'voxcpm', 'languages': ['zh', 'en'], 'voices': ['default'], 'default_voice': 'default', 'description': 'High quality Chinese/English'}}
examples.tts_multilingual.LANGUAGES
module-attribute
¶
LANGUAGES = {'en': {'name': 'English', 'kokoro_code': 'a'}, 'es': {'name': 'Español', 'kokoro_code': 'e'}, 'fr': {'name': 'Français', 'kokoro_code': 'f'}, 'de': {'name': 'Deutsch', 'kokoro_code': None}, 'it': {'name': 'Italiano', 'kokoro_code': 'i'}, 'pt': {'name': 'Português', 'kokoro_code': 'p'}, 'ja': {'name': '日本語', 'kokoro_code': 'j'}, 'zh': {'name': '中文', 'kokoro_code': 'z'}, 'ko': {'name': '한국어', 'kokoro_code': None}, 'hi': {'name': 'हिन्दी', 'kokoro_code': 'h'}, 'ru': {'name': 'Русский', 'kokoro_code': None}, 'ar': {'name': 'العربية', 'kokoro_code': None}, 'nl': {'name': 'Nederlands', 'kokoro_code': None}, 'pl': {'name': 'Polski', 'kokoro_code': None}, 'tr': {'name': 'Türkçe', 'kokoro_code': None}}
examples.tts_multilingual.get_best_model_for_language
¶
Get the best model for a given language.
Source code in examples/tts_multilingual.py
examples.tts_multilingual.list_models
¶
Print available models.
Source code in examples/tts_multilingual.py
examples.tts_multilingual.list_languages
¶
Print available languages and best models.
Source code in examples/tts_multilingual.py
examples.tts_multilingual.generate_speech
¶
Generate speech using the specified model.
Source code in examples/tts_multilingual.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
examples.tts_multilingual.main
¶
Source code in examples/tts_multilingual.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
Complete contract reference¶
Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.
examples.tts_multilingual.get_best_model_for_language · function
Get the best model for a given language.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
lang |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
str - Direct return expressions:
'kokoro';'voxcpm';'chatterbox'
Exceptions and behavior
Function get_best_model_for_language calls lang.lower; has 3 explicit return paths.
No direct raise statement appears in this definition.
examples.tts_multilingual.list_models · function
Print available models.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Function list_models calls print, MODELS.items, ', '.join, len.
No direct raise statement appears in this definition.
examples.tts_multilingual.list_languages · function
Print available languages and best models.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Function list_languages calls print, sorted, LANGUAGES.items, get_best_model_for_language.
No direct raise statement appears in this definition.
examples.tts_multilingual.generate_speech · function
examples.tts_multilingual.generate_speech(text: str, model_name: str, lang: str, voice: str, speed: float, output: str) -> not annotated
Generate speech using the specified model.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
text |
str |
yes |
none |
Required positional or keyword input. |
model_name |
str |
yes |
none |
Required positional or keyword input. |
lang |
str |
yes |
none |
Required positional or keyword input. |
voice |
str |
yes |
none |
Required positional or keyword input. |
speed |
float |
yes |
none |
Required positional or keyword input. |
output |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated - Direct return expressions:
None;output
Exceptions and behavior
Function generate_speech calls print, LANGUAGES.get(lang, {}).get, LANGUAGES.get, time.time; has 2 explicit return paths.
No direct raise statement appears in this definition.
examples.tts_multilingual.main · function
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, print; returns None.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated - Direct return expressions:
None
Exceptions and behavior
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, print; returns None.
No direct raise statement appears in this definition.
Complete symbol map¶
This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.
| Symbol | Kind | Signature and inputs | What it does | Source |
|---|---|---|---|---|
get_best_model_for_language |
function | get_best_model_for_language(lang: str) -> str |
Get the best model for a given language. | #L109-L123 |
list_models |
function | list_models() -> not annotated |
Print available models. | #L126-L138 |
list_languages |
function | list_languages() -> not annotated |
Print available languages and best models. | #L141-L152 |
generate_speech |
function | generate_speech(text: str, model_name: str, lang: str, voice: str, speed: float, output: str) -> not annotated |
Generate speech using the specified model. | #L155-L244 |
main |
function | main() -> not annotated |
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, print; returns None. |
#L247-L336 |