fetch; no Rime-specific npm package is required. This starter uses browser speech recognition and a stub response function, both of which you should replace for production.
Prerequisites
- A Rime API key from the API Tokens page, exported as
RIME_API_KEY - A Vite + React project (
npm create vite@latest -- --template react-tsdefaults work) - Express for the proxy:
npm install express
1. The TTS proxy server
Createserver.mjs in the project root:
server.mjs
vite.config.ts, so the browser can call a same-origin /api/tts:
vite.config.ts
test.mp3 should be playable audio. A 401 means RIME_API_KEY isn’t visible to server.mjs.
2. Client: mic in, Rime audio out
Replacesrc/App.tsx. It uses the browser’s built-in SpeechRecognition for input (Chrome/Edge/Safari), a stub respond() function as the agent brain, and the proxy for the voice:
src/App.tsx
http://localhost:5173, select Speak, say something, and the agent answers in Rime’s astra voice.
In production, deploy
server.mjs or fold the route into your existing backend, then serve Vite’s built assets from it. The same-origin /api/tts path keeps working, and the API key remains in the server environment.Add streaming when latency matters
For incremental synthesis, connect your server to Rime’s WebSocket API and relay events to the browser. Audio can then start while later sentences are still generating. Browser WebSockets cannot send the requiredAuthorization header, so the bridge stays server-side. The Next.js guide shows the bridge pattern; the Coda WebSocket reference defines the /ws3 message schema.
Production building blocks
WebSocket API overview
Endpoints, word-level timestamps, context IDs, and interruption handling.
Voices
Swap
astra for any Coda voice. Coda covers eight languages, and each voice serves one of them.Streaming formats
Choose between Opus, MP3, WAV, PCM, and μ-law for your latency budget.
TTS in five minutes
The core API walkthrough in cURL, Python, JavaScript, and TypeScript.

