# Chuyển văn bản thành giọng nói

**API:** Model API

**Endpoint:** `POST /api/v1/audio/speech`

**Tags:** Audio

Use model to select the speech generation model. Channel selection is unavailable for speech generation requests.

## Base URL

- `https://openapi.felo.ai` — Môi trường production

## Authentication

- `FeloBearerAuth` (http bearer) — Khóa API Felo được gửi dưới dạng `Authorization: Bearer <key>`.
- `FeloApiKey` (apiKey in header `X-API-Key`) — Khóa API Felo được gửi dưới dạng `X-API-Key: <key>`.

## Request body

Required: **yes**

### application/json

Schema:

```json
{
  "type": "object",
  "required": [
    "model",
    "input"
  ],
  "additionalProperties": false,
  "properties": {
    "model": {
      "type": "string",
      "maxLength": 256
    },
    "input": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096
    },
    "voice": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "description": "Optional non-blank voice ID. The upstream model determines whether a voice is required and which IDs it accepts. Catalog voices are examples."
    },
    "response_format": {
      "type": "string",
      "enum": [
        "pcm",
        "mp3"
      ],
      "default": "pcm"
    },
    "speed": {
      "type": "number",
      "default": 1,
      "description": "Currently only 1 is supported."
    }
  }
}
```

## Responses

### 200 — Thành công trả byte âm thanh: MP3 là `audio/mpeg`, PCM thô là `audio/pcm`, không phải WAV, JSON hay SSE. Kiểm tra HTTP và truyền xong trước khi phát. `--fail` tránh ghi lỗi HTTP vào tệp âm thanh. Bỏ tệp chưa hoàn chỉnh khi mất kết nối. Xác minh thông số PCM của kênh, không đoán. STT dùng `input_audio_second` hoặc token; TTS dùng `input_character`. Trong `speech_billing_unit`, `utf16_code_unit` và `unicode_code_point` đếm emoji khác nhau. Khoản giữ trước không phải trần chi phí; quyết toán có thể bất đồng bộ. Thiếu bằng chứng không có nghĩa miễn phí. Cả hai nhận `X-Felo-Channel` và gửi một lần đến kênh đã chọn. Tắt tự thử lại cả trong SDK sau timeout hoặc mất kết nối; lưu `X-Request-Id` và `X-Generation-Id` nếu có. Console Playground chưa hỗ trợ âm thanh. `configured_rates` dùng giá đã cố định và lượng dùng xác minh; `upstream_cost` dùng chi phí nhà cung cấp đã xác minh cùng mức cộng giá và chiết khấu công bố.

**audio/mpeg**

Schema: string, (binary)

```json
{
  "type": "string",
  "format": "binary"
}
```

**audio/pcm**

Schema: string, (binary)

```json
{
  "type": "string",
  "format": "binary"
}
```
