Create speech
Turn plain English text into studio-clean audio files or stream 24 kHz PCM audio in real time on spero-f1.
https://api.spero.audio/v1/audio/speechInteractive request builder
Configure voice, format, sample rate, tempo, or streaming below with live parameter validation.
Interactive builder
Configure your speech request
curl https://api.spero.audio/v1/audio/speech \
-H "Authorization: Bearer $SPERO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"spero-v1","voice":"spero-f1","input":"Your appointment is confirmed for Tuesday at 2:30 PM."}' \
--max-time 300 \
--output speech.mp3Request parameters
Send JSON with Authorization: Bearer sp_live_.... Any invalid parameter or unknown voice returns HTTP 400 with a plain message (see Errors & limits).
inputstringrequiredmodelstringoptionaldefault spero-v1voicestringoptionaldefault spero-f1spero-f1 (female, US English, supports files & streaming) or spero-m1 (male, US English, files only). Preview both on Models & voices.response_formatstringoptionaldefault mp3mp3, wav, flac, opus, pcm (16-bit LE mono, 24 kHz unless sample_rate says otherwise), or ulaw (headerless 8 kHz G.711 mu-law, audio/basic). With stream: true, defaults to pcm and accepts only pcm or wav.streambooleanoptionaldefault falsetrue, streams audio chunks as they are synthesized (~330 ms TTFB). Available on spero-f1 only; cannot be combined with speed or sample_rate.speedfloatoptionaldefault 1.0sample_rateintegeroptionaldefault 240008000, 16000, or 24000 Hz for wav, pcm, flac, and mp3. Omit for opus; omit or set to 8000 for ulaw. Files only.Code examples
curl https://api.spero.audio/v1/audio/speech \
-H "Authorization: Bearer $SPERO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "spero-v1", "input": "Your order ships on Tuesday.", "voice": "spero-f1"}' \
--max-time 300 \
--output speech.mp3Long text & render timing
Short passages up to 600 characters typically finish in a few seconds (~5 seconds for two sentences). Longer inputs up to 2,000 characters split cleanly at sentence boundaries and join seamlessly (~1 minute for a full 2,000 characters). Set your HTTP client timeout to at least 5 minutes for long whole-file renders.
Real-time streaming (stream: true)
For live voice agents and conversational playback, pass "stream": true with spero-f1. First audio bytes arrive after roughly 330 ms (location-dependent), faster than real-time playback. Streaming with spero-m1 returns 400.
curl https://api.spero.audio/v1/audio/speech \
-H "Authorization: Bearer $SPERO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "spero-v1", "input": "Your order ships on Tuesday.", "voice": "spero-f1", "stream": true, "response_format": "pcm"}' \
--no-buffer \
--output speech.pcmpcm(default when streaming): chunked 16-bit signed little-endian mono PCM at 24 kHz (Content-Type: audio/pcm;rate=24000;channels=1).wav: the same 24 kHz PCM16 samples behind an indeterminate-length WAV header for players that read until EOF.mp3,flac,opus, andulaware file-only. Leavespeedandsample_rateunset when streaming.
File vs. stream comparison
| Property | Whole file (stream: false) | Live stream (stream: true) |
|---|---|---|
| Delivery | Complete quality-checked audio file | Audio streamed immediately as generated |
| Time to first audio | ~5 s (2 sentences) to ~1 min (2,000 chars) | ~330 ms |
| Voices | All active voices (spero-f1, spero-m1) | spero-f1 |
| Formats | mp3, wav, flac, opus, pcm, ulaw | pcm, wav |
| Text limit | Up to 2,000 chars (max 12 paragraphs) | 1 paragraph, up to 600 chars |
X-Audio-Seconds | Present | Omitted (length unknown up front) |
| Mid-render failure | Returns JSON error, never charged | Connection dropped mid-stream, never charged |
Output options & telephony
Post-render options apply cleanly to whole-file requests at zero extra cost (billing is always by input characters):
speed(0.9 to 1.1): pitch-preserving tempo adjustment.X-Audio-Secondsreflects the adjusted duration.sample_rate(8000, 16000, or 24000): resampleswav,pcm,flac, ormp3. Apcmreply states its rate inContent-Type(e.g.audio/pcm;rate=16000;channels=1).response_format: "ulaw": headerless 8 kHz mono G.711 mu-law (audio/basic) ready for SIP / Twilio telephony bridges.
curl https://api.spero.audio/v1/audio/speech \
-H "Authorization: Bearer $SPERO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "spero-v1", "input": "Your order ships on Tuesday.", "voice": "spero-m1", "response_format": "ulaw"}' \
--max-time 300 \
--output speech.ulawResponse headers
| Header | Meaning |
|---|---|
X-Model | Model that rendered the audio (spero-v1). |
X-Voice | Voice ID that rendered the audio. |
X-Characters | Input characters billed. |
X-Audio-Seconds | Audio length in seconds after speed (files only). |
X-Cost-USD | Exact prepaid charge for this request. |
X-Queue-Wait-Ms | Time spent waiting before synthesis. |
X-Request-Id | Request ID listed on your Requests page. |
X-Disclosure | AI-generated audio (see terms for listener disclosure rules). |
Your data
Spero stores neither your input text nor the rendered audio. Only billing counts (characters, audio length, cost, and status) are recorded.