> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crazyrouter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Texto a voz (TTS)

> Convierte texto en voz usando POST /v1/audio/speech

> Contenido actualizado: 2026-06-06

# Texto a voz (TTS)

```
POST /v1/audio/speech
```

Convierte texto en voz natural, compatible con el formato de la API TTS de OpenAI.

## Parámetros de la solicitud

| Parámetro | Tipo | Obligatorio | Descripción |
| - | - | - | - |
| `model` | string | Sí | Nombre del modelo: `tts-1`, `tts-1`, `tts-1-hd-1106` |
| `input` | string | Sí | Texto a convertir, máximo 4096 caracteres |
| `voice` | string | Sí | Rol de voz |
| `response_format` | string | No | Formato de salida: `mp3` (por defecto), `opus`, `aac`, `flac`, `wav`, `pcm` |
| `speed` | number | No | Velocidad de la voz, 0.25-4.0, por defecto 1.0 |

### Voces disponibles

| Voz | Características |
| - | - |
| `alloy` | Neutral, equilibrada |
| `echo` | Masculina, serena |
| `fable` | Masculina, cálida |
| `onyx` | Masculina, profunda |
| `nova` | Femenina, animada |
| `shimmer` | Femenina, suave |

## Ejemplo de solicitud

```bash cURL theme={null}
curl -X POST https://api.crazyrouter.com/v1/audio/speech \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "tts-1",
    "input": "你好，欢迎使用 Crazyrouter API。今天天气真不错！",
    "voice": "nova",
    "response_format": "mp3",
    "speed": 1.0
  }' \
  --output speech.mp3
```

```python Python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.crazyrouter.com/v1"
)

response = client.audio.speech.create(
    model="tts-1",
    input="你好，欢迎使用 Crazyrouter API。今天天气真不错！",
    voice="nova",
    response_format="mp3",
    speed=1.0
)

response.stream_to_file("speech.mp3")
```

```javascript Node.js theme={null}
import OpenAI from "openai";
import fs from "fs";

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://api.crazyrouter.com/v1",
});

const response = await client.audio.speech.create({
  model: "tts-1",
  input: "你好，欢迎使用 Crazyrouter API。",
  voice: "nova",
});

const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("speech.mp3", buffer);
```

La respuesta es un flujo binario de archivo de audio, solo guárdalo directamente.

***

## Comparación de modelos

| Modelo | Calidad | Latencia | Descripción |
| - | - | - | - |
| `tts-1` | Estándar | Baja | Adecuado para escenarios en tiempo real |
| `tts-1-hd-1106` | Alta definición | Media | Voz más natural |
| `tts-1` | Máxima | Media | Último modelo, compatible con más idiomas y emociones |

> [!NOTE]
>
> `tts-1` es compatible con varios idiomas y detecta automáticamente el idioma del texto de entrada para usar la pronunciación correspondiente.

> [!WARNING]
>
> La respuesta es un flujo de audio binario, no es JSON. Utilice `--output` o escriba en archivos por streaming.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.