
<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
- Vobiz fetches
/answer/<token>and receives a bidirectional<Stream>that points at/ws/<token>. - Caller audio arrives as 20 ms
mediaframes of 16-bit PCM, and the server forwards them to agent STT. - Agent STT returns
AddSegmentmessages and anEndOfTurnwhen the caller has finished. A custom dictionary keeps brand names such as “Vobiz” spelled correctly. - 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
playAudiomessages, so the caller hears the first sentence while the rest is still being written. - 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. - When the LLM ends its goodbye, the server sends a
checkpoint, waits for Vobiz to confirm the goodbye has played, then sendsstopto hang up.
Step 1: Install and configure
ngrok http 8765) and copy its https:// URL. Then set these in python/.env:
.env
.env.example.
Step 2: Run it
Step 3: Place a call
- Call the agent
- Have the agent call you
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
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
- 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. - Vobiz sends
mediaframes labelledinboundoroutbound, each 20 ms of 16-bit PCM at 16 kHz. - The proxy queues each frame for its channel, and one
AsyncMultiChannelClientsession transcribes both, tagging each transcript with its channel. - 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
python/.env:
.env
Step 2: Run it
Step 3: Place a call
Open the printed Live transcript UI link in a browser, then callVOBIZ_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
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 setPATH_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
The call connects, then hangs up at once
The call connects, then hangs up at once
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.The voice agent is silent
The voice agent is silent
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.LLM error 400 or 404
LLM error 400 or 404
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.The agent stops too often
The agent stops too often
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 caller hears the notice, then the call ends
The caller hears the notice, then the call ends
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.No transcripts appear
No transcripts appear
If you heard the notice, Vobiz reached
/answer. Check that the proxy printed call started; if it did, check SPEECHMATICS_API_KEY.Could not configure the Vobiz number: 401, or number not found
Could not configure the Vobiz number: 401, or number not found
Check
VOBIZ_AUTH_ID and VOBIZ_AUTH_TOKEN, and that VOBIZ_PHONE_NUMBER is in E.164 form and belongs to that account.Address already in use on macOS
Address already in use on macOS
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.