# `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](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#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
    options:
      members:
        - MODELS
        - LANGUAGES
        - get_best_model_for_language
        - list_models
        - list_languages
        - generate_speech
        - main
      filters: []
      show_if_no_docstring: true

## 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.

<details class="api-contract" id="contract-examples.tts_multilingual.get_best_model_for_language" markdown="1">
<summary><code>examples.tts_multilingual.get_best_model_for_language</code> · function</summary>

```python
examples.tts_multilingual.get_best_model_for_language(lang: str) -> str
```

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.

[View source #L109-L123](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L109-L123).

</details>

<details class="api-contract" id="contract-examples.tts_multilingual.list_models" markdown="1">
<summary><code>examples.tts_multilingual.list_models</code> · function</summary>

```python
examples.tts_multilingual.list_models() -> not annotated
```

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.

[View source #L126-L138](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L126-L138).

</details>

<details class="api-contract" id="contract-examples.tts_multilingual.list_languages" markdown="1">
<summary><code>examples.tts_multilingual.list_languages</code> · function</summary>

```python
examples.tts_multilingual.list_languages() -> not annotated
```

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.

[View source #L141-L152](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L141-L152).

</details>

<details class="api-contract" id="contract-examples.tts_multilingual.generate_speech" markdown="1">
<summary><code>examples.tts_multilingual.generate_speech</code> · function</summary>

```python
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.

[View source #L155-L244](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L155-L244).

</details>

<details class="api-contract" id="contract-examples.tts_multilingual.main" markdown="1">
<summary><code>examples.tts_multilingual.main</code> · function</summary>

```python
examples.tts_multilingual.main() -> not annotated
```

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.

[View source #L247-L336](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L247-L336).

</details>

## 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`](#contract-examples.tts_multilingual.get_best_model_for_language) | function | `get_best_model_for_language(lang: str) -> str` | Get the best model for a given language. | [#L109-L123](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L109-L123) |
| [`list_models`](#contract-examples.tts_multilingual.list_models) | function | `list_models() -> not annotated` | Print available models. | [#L126-L138](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L126-L138) |
| [`list_languages`](#contract-examples.tts_multilingual.list_languages) | function | `list_languages() -> not annotated` | Print available languages and best models. | [#L141-L152](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L141-L152) |
| [`generate_speech`](#contract-examples.tts_multilingual.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](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L155-L244) |
| [`main`](#contract-examples.tts_multilingual.main) | function | `main() -> not annotated` | Function `main` calls `argparse.ArgumentParser`, `parser.add_argument`, `parser.parse_args`, `print`; returns `None`. | [#L247-L336](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/tts_multilingual.py#L247-L336) |
