Speech (TTS / STT)
Text-to-speech (TTS)
POST /v1/audio/speech
Converts text into speech and returns an audio binary stream.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | ✅ | TTS model, e.g. tts-1 (standard), tts-1-hd (HD) |
input | string | ✅ | Text to synthesize (up to 4096 characters) |
voice | string | ✅ | Voice, see options below |
response_format | string | — | Audio format: mp3 (default), opus, aac, flac, wav, pcm |
speed | number | — | Speed, range 0.25–4.0 (default 1.0) |
Available voices
| Voice | Style |
|---|---|
alloy | Neutral, balanced |
echo | Rich, steady |
fable | Warm, narrative |
onyx | Deep, authoritative |
nova | Lively, friendly |
shimmer | Soft, clear |
Example
bash
curl https://api.idreame.ai/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxx" \
-d '{
"model": "tts-1",
"input": "Welcome to iDreame Cloud, your one-stop entry to AI.",
"voice": "nova"
}' \
--output welcome.mp3python
from pathlib import Path
from openai import OpenAI
client = OpenAI(
base_url="https://api.idreame.ai/v1",
api_key="sk-xxxxxxxx",
)
response = client.audio.speech.create(
model="tts-1",
voice="nova",
input="Welcome to iDreame Cloud, your one-stop entry to AI.",
)
Path("welcome.mp3").write_bytes(response.content)Speech-to-text (STT)
POST /v1/audio/transcriptions
Converts an audio file into text (transcription). Upload the file with multipart/form-data.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | ✅ | Audio file (mp3, mp4, mpeg, mpga, m4a, wav, webm; up to 25MB) |
model | string | ✅ | Recognition model, e.g. whisper-1 |
language | string | — | Language code (e.g. zh, en); auto-detected if omitted |
prompt | string | — | Optional prompt to guide style or correct proper nouns |
response_format | string | — | Output format: json (default), text, srt, vtt, verbose_json |
temperature | number | — | Sampling temperature 0–1 |
Example
bash
curl https://api.idreame.ai/v1/audio/transcriptions \
-H "Authorization: Bearer sk-xxxxxxxx" \
-F "file=@recording.mp3" \
-F "model=whisper-1" \
-F "language=en"python
from openai import OpenAI
client = OpenAI(
base_url="https://api.idreame.ai/v1",
api_key="sk-xxxxxxxx",
)
with open("recording.mp3", "rb") as audio_file:
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file,
language="en",
)
print(transcript.text)Response example
json
{
"text": "Welcome to iDreame Cloud."
}Subtitle output
Set response_format=srt to output an SRT subtitle file directly:
bash
curl https://api.idreame.ai/v1/audio/transcriptions \
-H "Authorization: Bearer sk-xxxxxxxx" \
-F "file=@video_audio.mp3" \
-F "model=whisper-1" \
-F "response_format=srt"Output:
1
00:00:00,000 --> 00:00:02,500
Welcome to iDreame Cloud.
2
00:00:02,800 --> 00:00:05,200
Your one-stop entry to AI.