Skip to main content
Call the Text to Speech and Speech to Text APIs from your application. You do not need to build an agent first. The first HTTP example creates an audio file. The second returns a transcript. For streaming, see Stream in real time.

Before you begin

Set SLNG_API_KEY in your environment. If you need a key, follow Create your API key. If you already have one, see Store and use your key. The model requests below go to https://eu-west.slng.ai.ai and send your key as a bearer token.

Synthesize speech

Text to speech takes some text and a voice and returns audio. Pick the model in the request path and pass the text in the body. This example uses the Deepgram Aura model, where you choose the voice with the model parameter in the body. The endpoint returns binary audio, so write the response straight to a file.
The call above produces this audio:

Transcribe audio

Speech to text takes an audio file and returns the transcript. Send the file as multipart form data and read the text from the first alternative. The examples below transcribe this sample:
The transcript comes back under results.channels[0].alternatives[0].transcript.

Change the model or parameters

The model is part of the request path. Swap it to change the voice engine or the language, and keep the rest of the call the same. Prefer a variant under the slng/ prefix where one exists: those run on SLNG infrastructure in the region closest to you, so each call skips the hop to an outside provider. Each model has its own endpoint and its own parameters, so the field that picks the voice differs by provider. Deepgram Aura uses model, Rime Arcana uses speaker.
For speech to text, add optional fields to the form to tune the transcript:
  • language sets the recognition language.
  • diarize=true labels each speaker.
  • punctuate=true adds punctuation.
See WebSockets vs HTTP for request and response formats, and the Unified API guide for more details.

Stream in real time

For low-latency, turn-by-turn audio, connect over WebSocket at wss://eu-west.slng.ai.ai instead of posting a whole file.

Find other models and API details

Next steps