Skip to main content
Speechmatics Speechmatics builds speech recognition and speech synthesis for real-time voice: agent STT (Linden 1) for voice agents, the Realtime API for live transcription, and Text to Speech. A Vobiz <Stream> sends live call audio to your server as 16-bit PCM at 16 kHz, which Speechmatics accepts as it is, so nothing is transcoded. Source code: vobiz-ai/Vobiz-Speechmatics, two Python examples that each run as a single process, with no voice-agent framework or media server. The same examples are in the Speechmatics Academy.
Scope: inbound and outbound. Both examples answer calls to your Vobiz number, and both can place an outbound call (dial.py, proxy.py --call).

Requirements

  • A Vobiz account with a voice-enabled number, and your Auth ID and Auth Token from the Vobiz console.
  • A Speechmatics API key from the Speechmatics portal.
  • Python 3.12.
  • A public HTTPS tunnel to your machine, such as ngrok or cloudflared.
  • For the voice agent: an API key for an OpenAI-compatible LLM (Gemini by default, or OpenAI). Optionally an ElevenLabs or Cartesia key, if you choose that voice instead of Speechmatics TTS.
  • For live transcription: a second phone for Vobiz to bridge the call to.

Phone voice agent

A caller dials your Vobiz number and talks to an AI agent. The agent listens with Speechmatics agent STT, replies with an LLM, and speaks with streamed Text to Speech: Speechmatics TTS by default, or ElevenLabs or Cartesia.

How it works

  1. Vobiz fetches /answer/<token> and receives a bidirectional <Stream> that points at /ws/<token>.
  2. Caller audio arrives as 20 ms media frames of 16-bit PCM, and the server forwards them to agent STT.
  3. Agent STT returns AddSegment messages and an EndOfTurn when the caller has finished. A custom dictionary keeps brand names such as “Vobiz” spelled correctly.
  4. The LLM reply is split into sentences. Each sentence goes to Text to Speech as raw 16 kHz PCM and streams back to Vobiz in playAudio messages, so the caller hears the first sentence while the rest is still being written.
  5. Interruptions: any sound from the caller pauses the agent with clearAudio, but keeps the reply. If the caller says words, the reply is dropped; if no words follow within 2 seconds (a cough, an “mhm”), the agent carries on from the sentence it was cut off in.
  6. When the LLM ends its goodbye, the server sends a checkpoint, waits for Vobiz to confirm the goodbye has played, then sends stop to hang up.

Step 1: Install and configure

Start a tunnel to port 8765 in a second terminal (ngrok http 8765) and copy its https:// URL. Then set these in python/.env:
.env
To use OpenAI instead of Gemini, or ElevenLabs or Cartesia instead of Speechmatics TTS, follow the commented options in .env.example.

Step 2: Run it

It prints the answer and hangup URLs:

Step 3: Place a call

1

Create an application

In the Vobiz console, create a Voice Application with the printed Answer URL and Hangup URL, method POST.
2

Attach your number

Attach your Vobiz number to the application.
3

Call it

Dial the number from any phone and start talking.

What you’ll see

Output from a call:

The answer XML

Send playAudio with only event and media. Vobiz plays it on the stream it arrives on. checkpoint, clearAudio and stop carry the streamId from the start event.

Configuration reference

What the agent knows and how it talks is in assets/agent.md.
Speechmatics TTS speaks English voices. Agent STT supports the languages in the agent STT documentation; set SM_LANGUAGE to change it.

Live call transcription

Someone calls your Vobiz number and Vobiz bridges them to a second phone. While they talk, Vobiz copies both sides of the call to a local proxy, which sends them to one Speechmatics Realtime session with channel diarization. Each person is transcribed as a separate speaker, in the console and on a live web page.

How it works

  1. Vobiz fetches /answer/<token> and gets a one-way <Stream audioTrack="both">, a short <Speak> notice and a <Dial> to the second phone. A one-way stream does not block, so the call moves straight on to the notice and the bridge.
  2. Vobiz sends media frames labelled inbound or outbound, each 20 ms of 16-bit PCM at 16 kHz.
  3. The proxy queues each frame for its channel, and one AsyncMultiChannelClient session transcribes both, tagging each transcript with its channel.
  4. When the call ends, Vobiz closes the WebSocket (it sends no stop event). The proxy closes both channels and Speechmatics returns the final words.

Step 1: Install and configure

Set these in python/.env:
.env

Step 2: Run it

On startup the proxy creates or updates a Vobiz application named speechmatics-transcription-<number> and attaches VOBIZ_PHONE_NUMBER to it. If the number was attached to another application, it prints that application’s ID so you can re-attach it later. Run with --no-setup to leave the number’s routing alone.

Step 3: Place a call

Open the printed Live transcript UI link in a browser, then call VOBIZ_PHONE_NUMBER from any phone. You hear “This call is being transcribed”, FORWARD_TO_NUMBER rings, and once it is answered both sides are transcribed live. To have Vobiz place the first call instead, run python proxy.py --call +91XXXXXXXXXX. When that person answers, they are bridged to FORWARD_TO_NUMBER the same way. Bridged calls are billed to your Vobiz account.

What you’ll see

The answer XML

Don’t add bidirectional="true" here. A bidirectional stream carries only the inbound track and holds the call on the stream, so the bridge never happens.

Configuration reference


Security

The audio WebSocket is not signed, so both examples put a random path token in the answer URL, the hangup URL and the WebSocket path. The token changes on every run unless you set PATH_TOKEN (voice agent). Anyone with the token can open the stream, and for live transcription read every call’s transcript, so keep the URLs private. Neither example validates Vobiz webhook signatures: add signature validation before exposing a server for anything other than a test. Keep API keys in .env, which is ignored by git.

Troubleshooting

Vobiz could not fetch the answer URL. Check that the tunnel forwards to the right port (8765 for the voice agent, 5000 for transcription) and that the application’s answer URL matches the one printed, including the token. Restarting without PATH_TOKEN generates a new token.
Look for could not start a Speechmatics session or TTS error in the log and check SPEECHMATICS_API_KEY. For ElevenLabs, use the secret key that starts with sk_, not the key’s ID.
Check LLM_MODEL is available to your key. If the error mentions reasoning_effort, set LLM_REASONING_EFFORT= (empty); if it mentions temperature, set LLM_TEMPERATURE=default.
Any sound pauses the agent for up to 2 seconds, and each new burst of background noise restarts the pause. Test from a quiet room first.
The bridge did not connect. Check that FORWARD_TO_NUMBER is in E.164 form and that your account can call it; the call record in the Vobiz console shows the hangup cause.
If you heard the notice, Vobiz reached /answer. Check that the proxy printed call started; if it did, check SPEECHMATICS_API_KEY.
Check VOBIZ_AUTH_ID and VOBIZ_AUTH_TOKEN, and that VOBIZ_PHONE_NUMBER is in E.164 form and belongs to that account.
macOS uses port 5000 for AirPlay Receiver. Set SM_VOBIZ_PROXY_PORT=5050.

Next steps

Stream XML

Every <Stream> attribute, event and audio format.

Source code

Both examples, with tests, on GitHub.

Dial XML

Bridge calls to another number or SIP endpoint.

Other AI voice platforms

Every Vobiz integration in one place.