# แปลงข้อความเป็นเสียง

**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` หรือ token; TTS ใช้ `input_character` โดย `speech_billing_unit` แบบ `utf16_code_unit` กับ `unicode_code_point` นับ emoji ต่างกัน ยอดสำรองไม่ใช่เพดานค่าใช้จ่ายและอาจสรุปยอดแบบอะซิงโครนัส การขาดหลักฐานไม่แปลว่าฟรี ทั้งสอง 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"
}
```
