Skip to main content

Generate speech in 5 minutes

Before you start​

Create a project and an API key before making a request. See Get your API key for the complete steps.

export VUILABS_API_BASE_URL="https://api.vuilabs.ai"
export VUILABS_API_KEY="your-api-key"

Before running the request, replace YOUR_PROJECT_VOICE_ID with a voice available to this API key. It is not a shared demo voice; for a cloned voice, create it first with the Voice Cloning API.

Keep your key safe

Never share your API key or add it to public source code.

Generate your first audio​

curl --fail-with-body --request POST \
--url "$VUILABS_API_BASE_URL/v1/text-to-speech" \
--header "X-API-Key: $VUILABS_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"text": "Hello from VUILabs.",
"voice_id": "YOUR_PROJECT_VOICE_ID",
"language": "en",
"speed": 1
}' \
--dump-header speech.headers \
--output speech.response || { cat speech.response >&2; exit 1; }

if ! grep -Eiq '^content-type:[[:space:]]*audio/wav([[:space:];]|$)' speech.headers || [ ! -s speech.response ]; then
cat speech.response >&2
echo 'Expected a non-empty audio/wav response' >&2
exit 1
fi
mv speech.response speech.wav

What happens next​

The API returns raw audio bytes in an HTTP 200 response. Save the response to a file or pass it directly to an audio player.

✓

Need to specify a voice? Choose a voice_id enabled for the current project.

✓

Need the first audio chunk sooner? Switch to the streaming endpoint.

✓

Need a different audio format? Both complete and Luna-TTS streaming requests support WAV (default) or raw PCM. Send audio_format: "pcm" for PCM and read the response audio metadata before playback.

Continue to Voices and output, or see the full Text to Speech API reference.