Audio (TTS, STT, Translation)

Text-to-speech, speech-to-text, and audio translation across OpenAI, ElevenLabs, Deepgram, and Cartesia.

Overview

The Audio API exposes three operations behind a unified, OpenAI-compatible surface:

  • Text-to-Speech (/v1/audio/speech) -- synthesize speech from text
  • Speech-to-Text (/v1/audio/transcriptions) -- transcribe audio in its source language
  • Translation (/v1/audio/translations) -- transcribe audio and translate to English

You can route the same operation to different providers (OpenAI Whisper, Deepgram Nova-3, ElevenLabs, Cartesia Sonic, Google Cloud Speech) by changing the model identifier. Cost, latency, and language support vary; pick per use case.

Text-to-Speech

POST https://api.allroutes.ai/v1/audio/speech

Request Body

FieldTypeRequiredDescription
modelstringYesTTS model (e.g., tts-1, tts-1-hd, eleven_turbo_v2_5, cartesia-sonic)
inputstringYesText to synthesize (max 4096 characters)
voicestringYesVoice identifier (depends on model)
response_formatstringNomp3 (default), opus, aac, flac, wav, pcm
speedfloatNoPlayback speed 0.25-4.0 (default: 1.0)

Example

curl https://api.allroutes.ai/v1/audio/speech \
  -H "Authorization: Bearer allroutes_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "Hello, world. This is a test of text-to-speech.",
    "voice": "alloy",
    "response_format": "mp3"
  }' \
  --output speech.mp3

The response body is the raw audio bytes. The Content-Type header reflects the requested format.

Voice IDs

ModelAvailable Voices
tts-1 / tts-1-hdalloy, echo, fable, onyx, nova, shimmer
eleven_turbo_v2_5Any ElevenLabs voice ID
cartesia-sonicAny Cartesia voice ID
google-ttsen-US-Wavenet-A ... en-US-Wavenet-J, etc.

Speech-to-Text

POST https://api.allroutes.ai/v1/audio/transcriptions

Request Body (multipart/form-data)

FieldTypeRequiredDescription
filefileYesAudio file (mp3, mp4, mpeg, mpga, m4a, wav, webm; max 25 MB)
modelstringYesSTT model (e.g., whisper-1, deepgram-nova-3, groq-whisper-large-v3)
languagestringNoISO-639-1 hint (e.g., en, es, de); auto-detected when omitted
promptstringNoStyle hint or domain vocabulary
response_formatstringNojson (default), text, srt, vtt, verbose_json
temperaturefloatNo0.0-1.0 (default: 0.0)
timestamp_granularitiesarrayNo["word"], ["segment"], or both (verbose_json only)

Example

curl https://api.allroutes.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer allroutes_sk_..." \
  -F [email protected] \
  -F model=whisper-1 \
  -F response_format=verbose_json \
  -F "timestamp_granularities[]=segment"

Response (verbose_json)

{
  "task": "transcribe",
  "language": "english",
  "duration": 412.5,
  "text": "Welcome everyone. Today we'll cover...",
  "segments": [
    {"id": 0, "start": 0.0, "end": 4.2, "text": "Welcome everyone."},
    {"id": 1, "start": 4.2, "end": 8.1, "text": "Today we'll cover..."}
  ]
}

Translation

POST https://api.allroutes.ai/v1/audio/translations

Same request shape as transcription, but the model translates source-language audio into English text. Currently only whisper-1 and groq-whisper-large-v3 support translation.

curl https://api.allroutes.ai/v1/audio/translations \
  -H "Authorization: Bearer allroutes_sk_..." \
  -F file=@german_lecture.mp3 \
  -F model=whisper-1

SDK Examples

Python

# TTS
audio_bytes = client.audio.speech.create(
    model="tts-1",
    voice="alloy",
    input="Hello, world.",
)
with open("speech.mp3", "wb") as f:
    f.write(audio_bytes)

# STT
with open("meeting.mp3", "rb") as f:
    transcript = client.audio.transcriptions.create(
        model="whisper-1",
        file=f,
        response_format="verbose_json",
    )
print(transcript.text)

Node.js

import fs from "fs";

// TTS
const audio = await client.audio.speech.create({
  model: "tts-1",
  voice: "alloy",
  input: "Hello, world.",
});
fs.writeFileSync("speech.mp3", Buffer.from(await audio.arrayBuffer()));

// STT
const transcript = await client.audio.transcriptions.create({
  model: "whisper-1",
  file: fs.createReadStream("meeting.mp3"),
  response_format: "verbose_json",
});
console.log(transcript.text);

Supported Models

ModelOperationStrength
tts-1TTSCheap, fast, 6 voices
tts-1-hdTTSHigher fidelity, slower
eleven_turbo_v2_5TTSBest voice cloning, lowest latency
cartesia-sonicTTSSub-100ms first-byte latency
whisper-1STT99 languages, broad support
deepgram-nova-3STTBest English accuracy, low latency
groq-whisper-large-v3STT5-10x faster than OpenAI Whisper
assembly-bestSTTSpeaker diarization, sentiment

Streaming TTS

For low-latency voice applications, set stream: true to receive audio chunks as they're generated:

curl https://api.allroutes.ai/v1/audio/speech \
  -H "Authorization: Bearer allroutes_sk_..." \
  -H "Content-Type: application/json" \
  -d '{"model":"cartesia-sonic","voice":"...","input":"Hello","stream":true}' \
  --output - | mpv -

The chunked response is raw audio in the requested response_format. See Realtime API for full bidirectional voice agent flows.

Troubleshooting

SymptomCauseFix
400: file too largeAudio over 25 MBCompress to MP3 64kbps or split
Garbled transcriptionWrong language hintDrop language to auto-detect or fix the hint
TTS sounds roboticUsing tts-1 for productionSwitch to tts-1-hd, eleven_turbo_v2_5, or cartesia-sonic
Long queue timesProvider rate-limitAdd provider.order fallback or use BYOK

See Also