> ## Documentation Index
> Fetch the complete documentation index at: https://docs.venice.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The Venice API is OpenAI-compatible: use any OpenAI SDK with the base URL `https://api.venice.ai/api/v1` and a Venice API key, or pay per request from a USDC wallet through x402 with no account.
> Read model IDs from `GET /models` or `GET /models/traits` at runtime instead of hardcoding them from memory or from these pages. Models are added and retired often.
> Every model's price is in https://docs.venice.ai/pricing.md. Quote video and audio jobs with `POST /video/quote` or `POST /audio/quote` before you queue them.
> Search these docs from an MCP client at https://docs.venice.ai/mcp. The full agent guide is https://docs.venice.ai/agents.md.

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

> أنشئ صوتًا منطوقًا من النص باستخدام نماذج تحويل النص إلى كلام في Venice، واختر صوتًا خاصًا بالنموذج، واحفظ الاستجابة الثنائية من نقطة النهاية /audio/speech.

يحوّل تحويل النص إلى كلام النصَّ المكتوب إلى صوت منطوق. اختر نموذج TTS، وحدّد صوتًا يدعمه هذا النموذج، وأرسل النص إلى `/audio/speech`، ثم احفظ استجابة الصوت الثنائية.

استخدم هذا الدليل لتوليد الأصوات القياسية. إذا كنت تريد إنشاء كلام من صوت مرجعي مخصص، فراجع [استنساخ الصوت](https://docs.venice.ai/guides/media/voice-cloning.md).

## الاستخدام الأساسي

```python Python theme={"system"}
import os
from pathlib import Path

import requests

response = requests.post(
    "https://api.venice.ai/api/v1/audio/speech",
    headers={
        "Authorization": f"Bearer {os.environ['VENICE_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "tts-kokoro",
        "voice": "af_sky",
        "input": "Hello, welcome to Venice Voice.",
    },
)

response.raise_for_status()
Path("speech.mp3").write_bytes(response.content)
```

```javascript Node.js theme={"system"}
import { writeFile } from "node:fs/promises";

const response = await fetch("https://api.venice.ai/api/v1/audio/speech", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VENICE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "tts-kokoro",
    voice: "af_sky",
    input: "Hello, welcome to Venice Voice.",
  }),
});

if (!response.ok) {
  throw new Error(await response.text());
}

await writeFile("speech.mp3", Buffer.from(await response.arrayBuffer()));
```

```bash cURL theme={"system"}
curl https://api.venice.ai/api/v1/audio/speech \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-kokoro",
    "voice": "af_sky",
    "input": "Hello, welcome to Venice Voice."
  }' \
  --output speech.mp3
```

يكون جسم الاستجابة الناجحة صوتًا ثنائيًا بالصيغة الافتراضية للنموذج، وليس JSON. يستخدم `tts-kokoro` حاليًا صيغة MP3 كإعداد افتراضي.

## اختيار النموذج والصوت

الأصوات خاصة بكل نموذج. يجب أن تكون قيمة `voice` صالحة لـ `model` الذي تختاره.

استخدم صفحة [نماذج تحويل النص إلى كلام](https://docs.venice.ai/models/text-to-speech.md) لتصفّح النماذج والأصوات المتاحة. يعرض منتقي الأصوات معرّفات الأصوات الدقيقة التي تُمرّرها في طلبك.

> [!NOTE]
>
> معرّفات الأصوات حسّاسة لحالة الأحرف. إذا بدّلت نموذج TTS، فحدِّث قيمة `voice` في الوقت نفسه.

## بنية الطلب

| المعامِل | النوع | مطلوب | الوصف |
| - | - | - | - |
| `model` | string | نعم | معرّف نموذج تحويل النص إلى كلام. |
| `voice` | string | لا | معرّف الصوت المدعوم من النموذج المُختار. القيمة الافتراضية: خاصة بكل نموذج (يستخدم Kokoro القيمة `af_sky`). |
| `input` | string | نعم | النص المراد تحويله إلى كلام، حتى 4096 حرفًا. |
| `response_format` | string | لا | صيغة الإخراج المطلوبة: `mp3` أو `opus` أو `aac` أو `flac` أو `wav` أو `pcm`. الصيغ المدعومة والإعداد الافتراضي خاصة بكل نموذج. |

## صيغة الإخراج

يمكنك حذف `response_format` لاستخدام الإعداد الافتراضي للنموذج. قبل اختيار امتداد الملف أو تجاوز الصيغة، استعلم عن واجهة برمجة النماذج للحصول على قيمتَي `default_format` و`supported_formats` الحاليتين للنموذج:

```bash theme={"system"}
curl "https://api.venice.ai/api/v1/models?type=tts" \
  -H "Authorization: Bearer $VENICE_API_KEY" |
  jq '.data[] | select(.id == "tts-kokoro") | .model_spec | {default_format, supported_formats}'
```

يحدد `Content-Type` في الاستجابة صيغة الصوت المُعادة. طلب صيغة لا يدعمها النموذج المُختار يُعيد الحالة HTTP `400`.

## نصائح الإنتاج

* خزّن الصوت المُولَّد مؤقتًا عند إعادة استخدام النص المصدر والصوت.
* طبِّع النص وراجعه قبل التوليد. تؤثر علامات الترقيم في الإيقاع والتنغيم.
* خزّن المخرجات بامتداد الملف الصحيح المطابق لصيغة استجابة النموذج.

## موارد ذات صلة

> [!TIP]
>
> هل تريد سرد نص أطول من بضع جمل؟ يغطي دليل [سرد المقالات باستخدام تحويل النص إلى كلام](https://docs.venice.ai/guides/media/article-narration.md) حدَّ الإدخال البالغ 4096 حرفًا، وتقسيم النص على حدود الجمل، ودمج الأجزاء في ملف صوتي واحد، والبثّ للتشغيل التفاعلي.

* [واجهة برمجة تطبيقات الكلام الصوتي](https://docs.venice.ai/api-reference/endpoint/audio/speech.md)
* [نماذج تحويل النص إلى كلام](https://docs.venice.ai/models/text-to-speech.md)
* [سرد المقالات باستخدام تحويل النص إلى كلام](https://docs.venice.ai/guides/media/article-narration.md)
* [دليل استنساخ الصوت](https://docs.venice.ai/guides/media/voice-cloning.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.