صدا (TTS و STT)
دو اندپوینت صدا: POST /v1/audio/speech متن را به گفتار تبدیل میکند (خروجی MP3 یا PCM بسته به مدل) و POST /v1/audio/transcriptions گفتار را به متن برمیگرداند. هم با آپلود multipart و هم با JSON و صدای base64. هر دو با SDKهای OpenAI سازگارند.
/v1/audio/speechاحراز هویت BearerText-to-speech (TTS)
Convert text to spoken audio. Drop-in compatible with the OpenAI SDK's
client.audio.speech.create(...). Billed per character of input, per
second of generated audio, or both, as each model's page states; the
charge settles when the audio has been sent.
Every text-to-speech model in GET /v1/models (api_shape speech)
works here and on POST /v1/predictions. Voices are model-specific:
each model's input_fields lists its own. response_format is mp3
or pcm (24 kHz mono); when omitted the audio is PCM, so send mp3
to get an MP3 file.
بدنه درخواستالزامی
| فیلد | نوع | توضیح |
|---|---|---|
modelالزامی | string | نمونه: |
inputالزامی | string | نمونه: |
voiceالزامی | string | نمونه: |
response_format | string | پیشفرض: مقادیر مجاز: |
نمونه
پاسخها
200Audio bytestream.
/v1/audio/transcriptionsاحراز هویت BearerSpeech-to-text (STT)
Transcribe audio to text. Drop-in compatible with the OpenAI SDK's
client.audio.transcriptions.create(...) (multipart file upload). You
may also send the JSON shape
({model, input_audio:{data:<base64>, format}}) directly. Models:
every speech-to-text model in GET /v1/models (api_shape: transcriptions), e.g. openai/whisper-1, openai/gpt-4o-transcribe,
elevenlabs/scribe-v2, microsoft/mai-transcribe-2. OpenAI's bare
ids (whisper-1) work too. An unknown model is 404 MODEL_NOT_FOUND.
Price. Per minute of audio, or per token on the token-priced
models (gpt-4o-transcribe, gpt-4o-mini-transcribe,
gemini-3.5-transcribe); the rate is on each model's page. We measure
the audio's length before reserving credit, so the reserve matches the
recording; you are charged the reported usage.cost.
Inline audio only. Send the file (multipart file) or base64
input_audio.data; pcm is raw 16-bit mono at 16 kHz. A URL
(input_audio.url) is refused here: send it to POST /v1/predictions
(input.audio), which also suits long recordings. Audio whose length
cannot be read is 400.
Some models cap audio duration: google/chirp-3 accepts at most
60 seconds per request and answers anything longer with
400 AUDIO_DURATION_LIMIT, before anything is reserved. Split long
recordings, or use openai/whisper-large-v3 /
openai/gpt-4o-transcribe, which take multi-minute audio in one call.
diarize: true (with response_format: verbose_json) labels speakers
on the models that support it (ElevenLabs Scribe); others answer 400.
For Persian on Deepgram Nova-3, set language: "fa".
بدنه درخواستmultipart/form-dataالزامی
| فیلد | نوع | توضیح |
|---|---|---|
fileالزامی | string (binary) | |
modelالزامی | string | نمونه: |
response_format | string | |
language | string |
بدنه درخواستapplication/jsonالزامی
| فیلد | نوع | توضیح |
|---|---|---|
modelالزامی | string | نمونه: |
input_audioالزامی | object | |
dataالزامی | string | base64-encoded audio |
formatالزامی | string | مقادیر مجاز: |
language | string | ISO-639-1, e.g. fa; detected when omitted |
response_format | string | مقادیر مجاز: |
diarize | boolean | label speakers (verbose_json, supported models) |
نمونه
پاسخها
200Transcription result.