Skip to content

HTTP Server

A minimal HTTP server that exposes REST endpoints for text-to-speech synthesis. Useful as a reverse proxy — keeps your API key off the browser and lets your frontend call your own origin.

Terminal window
export RESPONSIVEVOICE_API_KEY="your-api-key" # https://app.responsivevoice.org
export RESPONSIVEVOICE_API_SECRET="your-api-secret" # "Server-to-server API secrets"
npm install
npm run server
# Server on http://localhost:3001
MethodPathDescription
GET/API documentation
GET/voicesList all voices
GET/voices/:langVoices by language
POST/synthesizeSynthesize speech (JSON body)
GET/synthesize?text=...Synthesize via query params
async function speak(text) {
const response = await fetch('http://localhost:3001/synthesize', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text, voice: 'UK English Female' }),
});
const audio = new Audio(URL.createObjectURL(await response.blob()));
audio.play();
}

The server ships with permissive CORS headers (Access-Control-Allow-Origin: *). Tighten to your domain(s) before deploying anything public-facing.