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

# واجهة برمجة تطبيقات تحويل النص إلى كلام من OpenAI (/v1/audio/speech)

> OpenAI generation API guide - Ace Data Cloud

تحويل النص إلى صوت طبيعي، **متوافق تمامًا مع `/v1/audio/speech` من OpenAI**. أي SDK من OpenAI يحتاج فقط إلى توجيه `base_url` إلى `https://api.acedata.cloud`، واستبدال المفتاح برمز AceData الخاص بك لاستخدامه مباشرة. تعيد الواجهة تدفق بايتات الصوت بشكل متزامن.

* **عنوان الطلب**: `POST https://api.acedata.cloud/v1/audio/speech` (اسم مستعار `POST /openai/audio/speech`)
* **المصادقة**: رأس الطلب `Authorization: Bearer {token}`
* **التسعير**: يتم احتساب الرسوم بناءً على عدد بايتات النص المطلوب، حوالي 85% من سعر OpenAI الرسمي (انظر الجدول أدناه).

## معلمات الطلب

| الحقل | النوع | مطلوب | الشرح |
| - | - | - | - |
| `input` | string | نعم | النص المراد تحويله. |
| `model` | string | لا | `tts-1` (أسرع) أو `tts-1-hd` (جودة صوت أعلى، الافتراضي). |
| `voice` | string | لا | واحد من `alloy`، `echo`، `fable`، `onyx`، `nova`، `shimmer`، الافتراضي `alloy`. |
| `response_format` | string | لا | `mp3` (افتراضي)، `opus`، `aac`، `flac`، `wav`، `pcm`. |
| `speed` | number | لا | سرعة الكلام 0.25–4.0، الافتراضي 1.0. |

## مثال

```shell theme={null}
curl -X POST 'https://api.acedata.cloud/v1/audio/speech' \
  -H 'authorization: Bearer {token}' \
  -H 'content-type: application/json' \
  -o speech.mp3 \
  -d '{
    "model": "tts-1-hd",
    "input": "ماذا لو كانت هناك واجهة برمجة تطبيقات واحدة تعطيك كل نموذج فيديو AI؟",
    "voice": "nova",
    "response_format": "mp3"
  }'
```

الرد هو ملف الصوت نفسه (`Content-Type: audio/mpeg`)، يمكن كتابته مباشرة في `speech.mp3` لتشغيله.

باستخدام SDK بايثون الرسمي من OpenAI:

```python theme={null}
from openai import OpenAI
client = OpenAI(base_url="https://api.acedata.cloud/v1", api_key="{token}")
client.audio.speech.create(model="tts-1-hd", voice="nova", input="مرحبًا من AceData.").stream_to_file("speech.mp3")
```

## الأسعار

| النموذج | السعر الرسمي من OpenAI | سعر هذه المنصة (حوالي 85% خصم) |
| - | - | - |
| `tts-1` | \$15 / 1 مليون حرف | حوالي \$12.75 / 1 مليون حرف |
| `tts-1-hd` | \$30 / 1 مليون حرف | حوالي \$25.5 / 1 مليون حرف |

> يتم احتساب الرسوم بناءً على عدد بايتات النص المطلوب؛ حقل `official_price` يعرض السعر الرسمي من OpenAI للمقارنة.

## رموز الخطأ

| رمز الحالة | code | الشرح |
| - | - | - |
| 400 | `bad_request` | `input` فارغ أو معلمات غير صالحة. |
| 401 | `authentication_failed` | الرمز غير صالح. |
| 403 | `used_up` | الرصيد غير كاف. |
| 429 | `too_many_requests` | الطلبات متكررة جدًا. |
| 500 | `api_error` | خطأ في النظام/داخلي. |


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