Soniox

Get started

Learn how to generate speech with the Soniox Text-to-Speech API.

Learn how to use the Soniox API in minutes

Soniox Text-to-Speech is built for the hardest parts of speech generation. It delivers native-speaker-quality speech in 60+ languages, with hallucination-free output and accurate pronunciation of alphanumerics such as phone numbers, email addresses, and IDs.

Soniox TTS is optimized for ultra-low latency and can start generating speech from the first few words, before the full sentence is available. It is available through WebSocket streaming and request-response generation over REST.

Use this guide to run your first Text-to-Speech request.

Get API key

Create a Soniox account and log in to the Console to get your API key.

API keys are created per project. In the Console, go to My First Project and click API Keys to generate one.

Export it as an environment variable (replace with your key):

Terminal
export SONIOX_API_KEY=<YOUR_API_KEY>

Get examples

Clone the official examples repo:

Terminal
git clone https://github.com/soniox/soniox_examples
cd soniox_examples/text_to_speech

Run examples

Terminal
cd python_sdk

# Set up environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Real-time TTS example (WebSocket)
python soniox_sdk_realtime.py --line "Hello from Soniox realtime Text-to-Speech."

# REST TTS example
python soniox_sdk_rest.py --text "Hello from Soniox REST Text-to-Speech."
Terminal
cd nodejs_sdk

# Install dependencies
npm install

# Real-time TTS example (WebSocket)
node soniox_sdk_realtime.js --line "Hello from Soniox realtime Text-to-Speech."

# REST TTS example
node soniox_sdk_rest.js --text "Hello from Soniox REST Text-to-Speech."
Terminal
cd python

# Set up environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Real-time TTS example (WebSocket)
python soniox_realtime.py --line "Hello from Soniox websocket Text-to-Speech."

# REST TTS example
python soniox_rest.py --text "Hello from Soniox REST Text-to-Speech."
Terminal
cd nodejs

# Install dependencies
npm install

# Real-time TTS example (WebSocket)
node soniox_realtime.js --line "Hello from Soniox websocket Text-to-Speech."

# REST TTS example
node soniox_rest.js --text "Hello from Soniox REST Text-to-Speech."

Next steps