# تبدیل متن به گفتار

**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` — تولید

## Authentication

- `FeloBearerAuth` (http bearer) — کلید API Felo که به‌صورت `Authorization: Bearer <key>` ارسال می‌شود.
- `FeloApiKey` (apiKey in header `X-API-Key`) — کلید API Felo که به‌صورت `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 — پاسخ موفق بایت صوتی است: MP3 با `audio/mpeg` یا PCM خام با `audio/pcm`، نه WAV، JSON یا SSE. پیش از پخش، وضعیت HTTP و کامل بودن انتقال را بررسی کنید. `--fail` از نوشتن خطای HTTP در فایل صوتی جلوگیری می‌کند. فایل ناقص را پس از قطع اتصال دور بیندازید. پارامترهای PCM کانال را بررسی کنید، حدس نزنید. STT از `input_audio_second` یا توکن و TTS از `input_character` استفاده می‌کند. در `speech_billing_unit`، ‏`utf16_code_unit` و `unicode_code_point` ایموجی را متفاوت می‌شمارند. رزرو سقف هزینه نیست؛ تسویه ممکن است ناهمگام باشد. نبود مدرک به معنی رایگان نیست. هر دو API، ‏`X-Felo-Channel` می‌پذیرند و یک بار به کانال منتخب می‌فرستند. تلاش مجدد خودکار، از جمله SDK، را پس از timeout یا قطع اتصال غیرفعال کنید؛ `X-Request-Id` و در صورت وجود `X-Generation-Id` را نگه دارید. Console Playground هنوز از صوت پشتیبانی نمی‌کند. `configured_rates` از نرخ ثابت و مصرف تأییدشده استفاده می‌کند؛ `upstream_cost` از هزینهٔ تأییدشدهٔ تأمین‌کننده با حاشیه و تخفیف منتشرشده.

**audio/mpeg**

Schema: string, (binary)

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

**audio/pcm**

Schema: string, (binary)

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