# Kokoro TTS (Mandarin Chinese)

> A highly efficient Mandarin Chinese text-to-speech model that captures natural tones and prosody.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/kokoro/mandarin-chinese`
- **Model ID**: `fal-ai/kokoro/mandarin-chinese`
- **Category**: text-to-audio
- **Kind**: inference
**Tags**: speech



## Pricing

- **Price**: $0.02 per 1000 characters

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`prompt`** (`string`, _required_)
  - Examples: "每一个伟大的旅程，都始于勇敢迈出的第一步。加油，你可以做到！"

- **`voice`** (`VoiceEnum`, _required_):
  Voice ID for the desired voice.
  - Options: `"zf_xiaobei"`, `"zf_xiaoni"`, `"zf_xiaoxiao"`, `"zf_xiaoyi"`, `"zm_yunjian"`, `"zm_yunxi"`, `"zm_yunxia"`, `"zm_yunyang"`
  - Examples: "zf_xiaobei"

- **`speed`** (`float`, _optional_):
  Speed of the generated audio. Default is 1.0. Default value: `1`
  - Default: `1`
  - Range: `0.1` to `5`



**Required Parameters Example**:

```json
{
  "prompt": "每一个伟大的旅程，都始于勇敢迈出的第一步。加油，你可以做到！",
  "voice": "zf_xiaobei"
}
```

**Full Example**:

```json
{
  "prompt": "每一个伟大的旅程，都始于勇敢迈出的第一步。加油，你可以做到！",
  "voice": "zf_xiaobei",
  "speed": 1
}
```


### Output Schema

The API returns the following output format:

- **`audio`** (`File`, _required_):
  The generated music
  - Examples: {"url":"https://fal.media/files/rabbit/8UiqobkQXPrYDRHl4l5oU_tmptz6jo3ex.wav"}



**Example Response**:

```json
{
  "audio": {
    "url": "https://fal.media/files/rabbit/8UiqobkQXPrYDRHl4l5oU_tmptz6jo3ex.wav"
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/kokoro/mandarin-chinese \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "prompt": "每一个伟大的旅程，都始于勇敢迈出的第一步。加油，你可以做到！",
     "voice": "zf_xiaobei"
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/kokoro/mandarin-chinese",
    arguments={
        "prompt": "每一个伟大的旅程，都始于勇敢迈出的第一步。加油，你可以做到！",
        "voice": "zf_xiaobei"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/kokoro/mandarin-chinese", {
  input: {
    prompt: "每一个伟大的旅程，都始于勇敢迈出的第一步。加油，你可以做到！",
    voice: "zf_xiaobei"
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/fal-ai/kokoro/mandarin-chinese)
- [API Documentation](https://fal.ai/models/fal-ai/kokoro/mandarin-chinese/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/kokoro/mandarin-chinese)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
