# تحويل النص إلى كلام

**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`. الحجز ليس سقف إنفاق؛ وقد تكون التسوية غير متزامنة. نقص الأدلة لا يعني المجانية. تقبل الواجهتان `X-Felo-Channel` وترسلان مرة واحدة للقناة المختارة. عطّل المحاولات التلقائية بما فيها SDK بعد انتهاء المهلة أو الانقطاع، واحتفظ بـ`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"
}
```
