Skip to content
Text to speech · Spero

Create speech

Turn plain English text into studio-clean audio files or stream 24 kHz PCM audio in real time on spero-f1.

OpenAI-compatible~330 ms streaming TTFB6 formats incl. 8 kHz ulaw$20 / 1M chars
POSThttps://api.spero.audio/v1/audio/speech

Interactive request builder

Configure voice, format, sample rate, tempo, or streaming below with live parameter validation.

Interactive builder

Configure your speech request

53 chars · $0.00106
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.mp3
200 · speech.mp353 chars$0.00106AI-generated audio

Request parameters

Send JSON with Authorization: Bearer sp_live_.... Any invalid parameter or unknown voice returns HTTP 400 with a plain message (see Errors & limits).

inputstringrequired
1 to 2,000 characters (at most 12 paragraphs; max 100 characters per word). With stream: true, send one paragraph of at most 600 characters.
modelstringoptionaldefault spero-v1
Model identifier. Defaults to spero-v1.
voicestringoptionaldefault spero-f1
spero-f1 (female, US English, supports files & streaming) or spero-m1 (male, US English, files only). Preview both on Models & voices.
response_formatstringoptionaldefault mp3
mp3, 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 false
When true, 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.0
Playback tempo from 0.9 to 1.1 with pitch preserved (files only). No extra cost.
sample_rateintegeroptionaldefault 24000
8000, 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.mp3

Long 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.pcm
  • pcm (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, and ulaw are file-only. Leave speed and sample_rate unset when streaming.

File vs. stream comparison

PropertyWhole file (stream: false)Live stream (stream: true)
DeliveryComplete quality-checked audio fileAudio streamed immediately as generated
Time to first audio~5 s (2 sentences) to ~1 min (2,000 chars)~330 ms
VoicesAll active voices (spero-f1, spero-m1)spero-f1
Formatsmp3, wav, flac, opus, pcm, ulawpcm, wav
Text limitUp to 2,000 chars (max 12 paragraphs)1 paragraph, up to 600 chars
X-Audio-SecondsPresentOmitted (length unknown up front)
Mid-render failureReturns JSON error, never chargedConnection 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-Seconds reflects the adjusted duration.
  • sample_rate (8000, 16000, or 24000): resamples wav, pcm, flac, or mp3. A pcm reply states its rate in Content-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.ulaw

Response headers

HeaderMeaning
X-ModelModel that rendered the audio (spero-v1).
X-VoiceVoice ID that rendered the audio.
X-CharactersInput characters billed.
X-Audio-SecondsAudio length in seconds after speed (files only).
X-Cost-USDExact prepaid charge for this request.
X-Queue-Wait-MsTime spent waiting before synthesis.
X-Request-IdRequest ID listed on your Requests page.
X-DisclosureAI-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.