> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.omicx.one/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.omicx.one/_mcp/server.

# Text to Speech

Để nhận các sự kiện dưới đây, đăng ký webhook với `events` chứa mã
`AI_TTS:COMPLETED` và/hoặc `AI_TTS:FAILED` (xem [Danh sách sự kiện hỗ trợ](/integrations/webhooks/webhook-event-catalog)).

## AI_TTS:COMPLETED

Gửi khi job Text to Speech (`POST /tts`) xử lý xong. `data` giống hệt
response của endpoint đồng bộ tương ứng (`TtsResponse`).

```json
{
  "event": "AI_TTS:COMPLETED",
  "data": {
    "trackingId": "018f8b3c-6d1b-7a2c-8e4f-5b6c7d8e9f0a",
    "audioUrl": "https://api.omicx.one/tts/audio?k=MDE5ZjY4ZmE...",
    "audioDuration": 3.4,
    "fileSizeBytes": 68432,
    "languageCode": "vi",
    "processingTimeMs": 512
  }
}
```

**Lưu ý:** `audioUrl` trỏ tới endpoint tải xuống self-host của
public-service (`GET /tts/audio`), sống tối đa 30 ngày theo TTL file.

## AI_TTS:FAILED

Gửi khi job Text to Speech (`POST /tts`) xử lý thất bại. `data` dùng
chung định dạng lỗi (`ErrorResponse`) như endpoint đồng bộ.

```json
{
  "event": "AI_TTS:FAILED",
  "data": {
    "error": {
      "code": "BAD_GATEWAY",
      "subCode": "AI_PROVIDER_ERROR",
      "message": "TTS processing failed",
      "timestamp": "2026-01-01T00:00:00Z",
      "path": "/tts"
    }
  }
}
```

Danh mục sự kiện hiện chỉ hỗ trợ 4 loại trên (`AI_STT`/`AI_TTS`,
`COMPLETED`/`FAILED`) — đây là danh mục chỉ thêm mới (append-only), OMICX
có thể bổ sung thêm sự kiện khác trong tương lai.