Deploy Speaches
Self-hosted OpenAI-compatible speech-to-text and text-to-speech API
Just deployed
/home/ubuntu/.cache/huggingface/hub
Deploy and Host Speaches on Railway
Speaches is an open-source (MIT) server that speaks the OpenAI audio API. It transcribes and translates speech with faster-whisper, turns text into speech with Kokoro or Piper, and adds voice activity detection and an OpenAI-style Realtime API. Any OpenAI SDK can use it by changing the base URL.
About Hosting Speaches
This template runs one Speaches service on CPU, built from a small public GitHub repo that pins the official ghcr.io/speaches-ai/speaches:0.9.0-rc.3-cpu image by digest. Models live on a Railway volume, so they download once (about 400 MB for the two defaults) and later deploys start in seconds. API_KEY is generated at deploy and protects every /v1 route; the server refuses to start without it. /health stays public for Railway's health check. After deploy, copy API_KEY from the service's Variables tab, open the public URL for the playground, or point your OpenAI client at https://YOUR-DOMAIN/v1. Plan for about 1 GB of RAM with the defaults, more for larger Whisper models.
Common Use Cases
- Self-hosted replacement for OpenAI's
/v1/audio/transcriptions,/v1/audio/translationsand/v1/audio/speechendpoints - Speech to text and text to speech for Open WebUI, n8n, Home Assistant or your own app, without sending audio to a third party
- Voice agents and live captions through the OpenAI-compatible Realtime API over WebSocket
Dependencies for Speaches Hosting
- A Railway volume for the Hugging Face model cache (included)
- Outbound access to huggingface.co to download models on first boot
Deployment Dependencies
- Speaches source and docs: https://github.com/speaches-ai/speaches and https://speaches.ai
- Release used: https://github.com/speaches-ai/speaches/releases/tag/v0.9.0-rc.3
- Template repo (Dockerfile, start script, changelog): https://github.com/aalfath/speaches-railway-template
Implementation Details
What the template sets up:
- Service
Speacheson port 8000 with a Railway domain: the Gradio playground at/, the API at/v1, API docs at/docs, health check at/health. - Volume at
/home/ubuntu/.cache/huggingface/hub, handed to the image's unprivilegedubuntuuser at startup, so the server never runs as root. PRELOAD_MODELSdownloadsSystran/faster-whisper-smallandspeaches-ai/Kokoro-82M-v1.0-ONNXat startup. Speaches never downloads a model on demand, so add any other model to this list (for exampleSystran/faster-whisper-large-v3) or callPOST /v1/models/MODEL-IDwith your key. The OpenAI nameswhisper-1,tts-1andtts-1-hdmap to the preloaded models.- The playground page is public but does nothing until you paste
API_KEYinto its API Key box.
Try it:
curl https://YOUR-DOMAIN/v1/audio/speech -H "Authorization: Bearer YOUR-API-KEY" -H "Content-Type: application/json" -d '{"model":"tts-1","voice":"af_heart","input":"Hello from Railway"}' -o hello.mp3
curl https://YOUR-DOMAIN/v1/audio/transcriptions -H "Authorization: Bearer YOUR-API-KEY" -F file=@hello.mp3 -F model=whisper-1
Optional settings (add them as variables only if you need them): ALLOW_ORIGINS (a JSON list, for browser apps calling the API directly), CHAT_COMPLETION_BASE_URL and CHAT_COMPLETION_API_KEY (an OpenAI-compatible LLM for the voice-chat tab and Realtime responses), STT_MODEL_TTL and TTS_MODEL_TTL (seconds before an idle model is unloaded from memory, default 300), and HF_TOKEN (only for gated models).
Updates: the template builds from the GitHub repo above. When a new Speaches version is pinned there, Railway shows an "update available" notice on your service. Read the repo's CHANGELOG first, then apply it. Your models stay on the volume.
Why Deploy Speaches on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Speaches on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content

