httpx call.
Prerequisites
- A Rime API key from the API Tokens page, exported as
RIME_API_KEY - Python 3.10+ with
pip install fastapi uvicorn httpx
1. Server: FastAPI app with a TTS endpoint
Createmain.py:
main.py
test.mp3 should be playable audio. A KeyError: 'RIME_API_KEY' at startup means the environment variable isn’t set.
2. Client: mic in, Rime audio out
Createindex.html next to main.py. It uses the browser’s built-in SpeechRecognition for input (Chrome/Edge/Safari), a stub respond() function as the agent brain, and your /api/tts endpoint for the voice:
index.html
http://localhost:8000, click Speak, say something, and the agent answers in Rime’s astra voice.
Want streaming?
For incremental synthesis — audio starts playing while later sentences are still generating — connect your server towss://users-ws.rime.ai/ws3 with the Python websockets library and relay events to the browser (FastAPI’s own WebSocket support works well as the browser-facing side). Rime’s WebSocket endpoints authenticate with an Authorization header, which browser WebSockets cannot send, so the bridge always lives server-side. Runnable Python connection code and the full /ws3 message schema are in the Coda WebSocket reference.
Next steps
WebSocket API overview
Endpoints, word-level timestamps, context IDs, and interruption handling.
Voices
Swap
astra for any Coda voice across six languages.Streaming formats
Choose between Opus, MP3, WAV, PCM, and μ-law for your latency budget.
Pipecat
Building a full Python voice pipeline? Use the ready-made Rime plugin.

