Self-Host Speaches: Build a Local OpenAI-Compatible Speech API with Whisper and Kokoro (2026 Guide)
Your application can already send chat requests to a local model, but speech is often the missing piece: users still have to upload recordings to a hosted transcription service or pay a separate text-to-speech provider. Speaches gives developers a local-first alternative: one OpenAI-compatible HTTP service for speech-to-text and text-to-speech, with faster-whisper for transcription and Kokoro or Piper for speech generation.
In this guide, you will run Speaches with Docker Compose, persist its model cache, download one transcription model and one voice model, then call both endpoints with curl and Python. You will also see how to connect its transcription endpoint to Open WebUI without confusing a container's localhost with your host machine.
What you are building
The resulting service exposes familiar audio API routes on your own machine:
POST /v1/audio/transcriptions— audio file to text, using a downloaded speech-recognition model.POST /v1/audio/speech— text to an audio file, using a downloaded text-to-speech model.GET /v1/modelsandGET /v1/registry— inspect installed models and models available to download.
The important distinction is that Speaches is an audio inference server, not a general-purpose chat model runtime. It does not replace Ollama or LM Studio for ordinary text generation. It can, however, give an application a local speech API that looks familiar to code already written for OpenAI-style audio endpoints.
How Speaches works
Speaches is an open-source server that implements OpenAI-compatible audio routes. Its project documentation describes faster-whisper for speech recognition and Kokoro or Piper for speech synthesis. It supports CPU and GPU deployments, model discovery and download, model loading and unloading, and streaming transcription. The actual model files are downloaded separately and cached on disk; starting the container alone does not mean every model is already installed.
For this walkthrough, the examples use Systran/faster-whisper-small for transcription and speaches-ai/Kokoro-82M-v1.0-ONNX for speech generation. These are example model IDs, not universal performance recommendations. Check the current registry and each model card before choosing a model for another language, hardware profile or commercial application.
Prerequisites
- Docker Engine or Docker Desktop with Docker Compose v2.
- A terminal with
curl.opensslis used below to generate a local API secret. - Enough free disk space for the container image and the models you download. Model sizes vary.
- A CPU is sufficient for a first test. An NVIDIA GPU can accelerate supported workloads, but requires a working NVIDIA driver and NVIDIA Container Toolkit integration with Docker.
- For the Python examples: Python and permission to install the
openaiandhttpxpackages.
Use a short, non-sensitive audio sample for the first test. The first model download needs network access to the model host; once the required files are cached, inference can run locally without sending the audio to a hosted speech API.
Version note before installing
Checked on 23 November 2026: the Speaches GitHub releases page marks v0.9.0-rc.3 as its latest listed release, while the hosted API reference currently identifies its OpenAPI schema as 0.8.3. That is a documentation/release-version mismatch, so do not assume the documentation site and every container tag are perfectly synchronized. This guide follows the project's current installation and usage documentation. For a production deployment, choose a known-good release or image digest, test it in staging, and record the exact version you deployed rather than relying indefinitely on a floating latest tag.
Step 1: Download the official Compose files
Start with the CPU configuration. It is the simplest path because it does not require GPU passthrough. Create a clean directory and download the two Compose files from the project's official repository:
mkdir speaches-local
cd speaches-local
curl -fsSLO https://raw.githubusercontent.com/speaches-ai/speaches/master/compose.yaml
curl -fsSLO https://raw.githubusercontent.com/speaches-ai/speaches/master/compose.cpu.yaml
export COMPOSE_FILE=compose.cpu.yaml
The CPU file extends the base Compose service and mounts a named volume for the Hugging Face model cache. That volume matters: without persistent storage, removing and recreating a container can force you to download model files again.
Keep the first deployment on loopback
The upstream base Compose file currently publishes port 8000 without restricting the host interface. For a local development service, edit compose.yaml and change its port mapping from:
ports:
- 8000:8000
to:
ports:
- "127.0.0.1:8000:8000"
This makes the host-published port reachable from the same machine, rather than advertising it on every network interface. Do this before starting the container.
Step 2: Add an API key and start the server
Speaches can run without an API key, but an unauthenticated service is reachable by anyone who can reach its listening address. Configure a random key even for a local setup:
printf 'API_KEY=%s\nENABLE_UI=false\nLOG_LEVEL=info\n' "$(openssl rand -hex 32)" > .env
chmod 600 .env
The official base Compose file loads this optional .env file into the container. API_KEY enables bearer-token authentication for API requests. ENABLE_UI=false disables the bundled Gradio UI; the examples below use the HTTP API directly.
Start the service:
docker compose up -d
docker compose ps
docker compose logs --tail=100 speaches
Check the health endpoint:
curl -fsS http://127.0.0.1:8000/health
Expected result: the container is running and the health endpoint returns a successful response. A healthy server does not prove that a speech model is installed yet; model downloads are the next step.
Load the local settings into your current shell so the following commands can reuse the secret:
set -a
. ./.env
set +a
export SPEACHES_BASE_URL=http://127.0.0.1:8000
Keep .env out of Git. If you share this directory, add .env to .gitignore.
Optional: use an NVIDIA GPU
If Docker can already access your NVIDIA GPU, download the CUDA Compose file and switch the Compose configuration:
curl -fsSLO https://raw.githubusercontent.com/speaches-ai/speaches/master/compose.cuda.yaml
export COMPOSE_FILE=compose.cuda.yaml
docker compose up -d
docker compose logs --tail=100 speaches
The current upstream CUDA Compose file uses a CUDA 12.6.3 image and requests all available NVIDIA devices. Your host still needs a compatible driver and NVIDIA Container Toolkit setup. If your Docker host is configured for CDI devices, the project also provides compose.cuda-cdi.yaml; follow the official installation page for that path. Do not select a CUDA file simply because the host has an NVIDIA GPU: first verify that a normal Docker container can see the device.
To return to CPU mode in a later shell, set COMPOSE_FILE=compose.cpu.yaml again. The two variants share the named model-cache volume when used with the same project directory.
Step 3: Discover and download speech models
Speaches separates the model registry from the installed-model list. Query the registry to see which speech-recognition models are available:
curl -fsS "$SPEACHES_BASE_URL/v1/registry?task=automatic-speech-recognition" \
-H "Authorization: Bearer $API_KEY"
Download a small multilingual Whisper model for the initial test:
curl -fsS -X POST \
"$SPEACHES_BASE_URL/v1/models/Systran/faster-whisper-small" \
-H "Authorization: Bearer $API_KEY"
Now inspect the installed model list:
curl -fsS "$SPEACHES_BASE_URL/v1/models" \
-H "Authorization: Bearer $API_KEY"
Download the Kokoro ONNX voice model for text-to-speech:
curl -fsS -X POST \
"$SPEACHES_BASE_URL/v1/models/speaches-ai/Kokoro-82M-v1.0-ONNX" \
-H "Authorization: Bearer $API_KEY"
The first download can take time. Watch the server logs if a request appears to stall:
docker compose logs -f speaches
Expected result: both model IDs appear in /v1/models. Speaches stores downloaded model files in its Hugging Face cache directory; the supplied Compose configuration mounts that directory into a named volume so the files survive container recreation.
You can also use the project's speaches-cli through uvx for registry and model operations. The HTTP examples above are useful when API-key authentication is enabled because they explicitly send the bearer token.
Step 4: Transcribe an audio file with curl
Place a short recording named meeting.wav in the current directory. Send it as multipart form data to the transcription endpoint:
curl -fsS "$SPEACHES_BASE_URL/v1/audio/transcriptions" \
-H "Authorization: Bearer $API_KEY" \
-F "[email protected]" \
-F "model=Systran/faster-whisper-small"
The response contains the transcript text. If the file is not named meeting.wav, update the file path. The selected model must already be installed and must support the audio and language you are testing.
For another supported model, inspect the registry first instead of guessing a model identifier. A model's repository name, task tags and supported languages are separate from its display name in a third-party application.
Step 5: Generate speech with Kokoro
Use the speech endpoint to turn text into an MP3 file:
curl -fsS "$SPEACHES_BASE_URL/v1/audio/speech" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-o welcome.mp3 \
-d '{
"model": "speaches-ai/Kokoro-82M-v1.0-ONNX",
"voice": "af_heart",
"input": "Your local speech API is ready.",
"response_format": "mp3"
}'
Open welcome.mp3 and confirm that audio was generated. The official example uses the af_heart voice with the Kokoro model. Check the current model documentation for available voices; the project's docs note that a complete voice-list example is still a work in progress. Do not assume every voice ID works with every TTS model.
Speaches' documented TTS endpoint also accepts a speed parameter and supports WAV output. The current documentation lists opus and aac as unsupported response formats, so use a documented format such as MP3 or WAV.
Step 6: Call the same service from Python
Because the API follows OpenAI-compatible audio request shapes, the OpenAI Python SDK can point at your local base URL. Create a virtual environment and install the client:
python -m venv .venv
source .venv/bin/activate
pip install openai httpx
Export the key for the Python process:
export SPEACHES_API_KEY="$API_KEY"
Create speech_demo.py:
import os
from pathlib import Path
import httpx
from openai import OpenAI
base_url = "http://127.0.0.1:8000/v1"
api_key = os.environ["SPEACHES_API_KEY"]
client = OpenAI(base_url=base_url, api_key=api_key)
# Speech-to-text
with Path("meeting.wav").open("rb") as audio_file:
transcript = client.audio.transcriptions.create(
model="Systran/faster-whisper-small",
file=audio_file,
)
print("Transcript:")
print(transcript.text)
# Text-to-speech
response = httpx.post(
f"{base_url}/audio/speech",
headers={"Authorization": f"Bearer {api_key}"},
json={
"model": "speaches-ai/Kokoro-82M-v1.0-ONNX",
"voice": "af_heart",
"input": f"Here is the transcript. {transcript.text}",
"response_format": "mp3",
},
timeout=180.0,
)
response.raise_for_status()
Path("transcript-audio.mp3").write_bytes(response.content)
print("Wrote transcript-audio.mp3")
Run it:
python speech_demo.py
This small pipeline transcribes a recording and then reads the transcript aloud. It is a useful starting point for meeting-note tools, private voice memos, accessibility features, internal knowledge capture or audio-enabled developer utilities. It is not a production job queue: add upload limits, background processing, retries, cancellation and per-user authorization before exposing it to multiple users.
Step 7: Connect Speaches to Open WebUI
Speaches documents an Open WebUI integration for speech-to-text. In Open WebUI, open the administrator settings, choose the Audio section, and set the Speech-to-Text Engine to OpenAI. Set the API base URL to the address Open WebUI can reach, then supply the transcription model.
- If both containers are on the same Docker network, use
http://speaches:8000/v1. - If Open WebUI runs directly on the host, use
http://127.0.0.1:8000/v1. - If Open WebUI is in another container or on another machine, use a reachable service name or private host address. Do not use
localhostinside one container to refer to a different container. - Use the same Speaches API key when authentication is enabled. The placeholder key shown in the upstream Open WebUI example applies to an unauthenticated Speaches server, not to a server protected by your own
API_KEY. - Set the model field to the installed model ID, such as
Systran/faster-whisper-small.
Save the settings and test with a short voice message. The upstream integration guide currently documents the speech-to-text configuration; do not assume that configuring STT automatically configures every text-to-speech feature in Open WebUI.
Step 8: Tune model residency and operate the service
Speaches exposes separate time-to-live settings for speech-recognition and speech-synthesis models. The documented defaults unload an STT or TTS model after 300 seconds of inactivity. Set a longer TTL if repeated requests are more important than freeing memory, or a shorter TTL if the machine is shared with other workloads. A value of -1 means do not unload the model; 0 means unload immediately after use.
For example, add these settings to .env and recreate the service:
STT_MODEL_TTL=900
TTS_MODEL_TTL=900
docker compose up -d
These settings trade memory residency for warm-start latency. Measure them on your own hardware rather than assuming one value is best for every machine.
Useful operational commands:
# Follow server logs
docker compose logs -f speaches
# Show service state
docker compose ps
# Stop the service but keep the named model cache
docker compose down
# Start it again
docker compose up -d
# Remove containers and named volumes, including cached models
docker compose down -v
Be careful with docker compose down -v: it removes the model-cache volume, so the next setup may need to download the models again.
Troubleshooting
The health endpoint works, but transcription returns a model error
A running server does not automatically mean the requested model is installed. Check /v1/models, confirm the exact model ID, and download it through the model endpoint or speaches-cli. The registry and installed-model list are not interchangeable.
The API returns 401 or 403
Confirm that the client sends Authorization: Bearer YOUR_KEY and that the key matches the container's API_KEY. Recreate the container after changing .env. Do not paste a real secret into a public issue or shell history.
The service cannot download a model
Check outbound connectivity, DNS, available disk space and the container logs. Model downloads use the model host and are cached locally. A restricted network may need an approved proxy or pre-populated cache; do not copy random cache folders from another environment and assume they are compatible.
CPU inference is too slow
Try a smaller model and shorter sample first. Larger Whisper models can improve recognition in some conditions but require more compute and memory. Compare accuracy on your own recordings and language mix; do not rely on generic speed claims.
The CUDA container does not see the GPU
Verify the host driver and NVIDIA Container Toolkit before debugging Speaches itself. Check Docker GPU passthrough with a separate CUDA test container. Also confirm that you selected the correct Compose variant: standard NVIDIA device reservations and CDI are different configurations.
Open WebUI cannot reach Speaches
Check that both services share a Docker network and use the correct service hostname and container port. 127.0.0.1 inside Open WebUI points back to the Open WebUI container, not to Speaches. Inspect both containers' logs and test the URL from inside the Open WebUI container.
The built-in Speaches UI fails when API authentication is enabled
Keep the API integration separate from the bundled Gradio interface. An upstream issue has reported a Web UI transcription authentication problem when API_KEY is set. This guide disables the bundled UI and uses the documented HTTP API instead. Check the issue tracker for its current status before relying on that interface.
Security and privacy checklist
- Bind to loopback for local development. Do not publish an unauthenticated speech service on
0.0.0.0or a public VPS. - Use a strong API key. Keep it in a protected environment file or secret manager, rotate it if exposed, and never commit it to source control.
- Understand the authentication boundary. The documentation says
/health,/docs,/openapi.jsonand the bundled Web UI remain accessible without authentication even whenAPI_KEYis configured. A key is not a substitute for network isolation. - Use HTTPS and an access-controlled reverse proxy if clients outside the machine must connect. Add rate limits, request-size limits, timeouts and firewall rules.
- Treat recordings as sensitive data. Local inference can keep audio on your infrastructure, but logs, backups, temporary files and model downloads still need a retention policy.
- Review model and voice licences. The server's licence does not automatically determine the licence or permitted use of every model, voice or dataset you download.
- Do not trust transcripts as ground truth. Review important names, amounts, legal statements and operational instructions before acting on them.
Frequently asked questions
Is Speaches an alternative to Ollama?
Only for a different part of the stack. Speaches focuses on audio inference such as transcription and speech generation. Ollama is a general local LLM runtime. The two can be used together in an application that needs both language generation and speech.
Does Speaches require a GPU?
No. The project provides a CPU Compose configuration. GPU acceleration is optional and requires a correctly configured runtime. CPU performance depends on the model and recording length.
Does it send my recordings to OpenAI?
Not when your client points to your own Speaches instance and that instance runs the selected local models. The initial model download still contacts the model host. Verify your application base URL and network egress rules if the privacy boundary matters.
Can I use the OpenAI Python SDK?
Yes. Set the SDK's base URL to your Speaches server and provide a non-empty API key. The key can be a placeholder only when the server itself has no authentication configured; otherwise use the real Speaches API key.
Can Speaches generate speech in every language?
No universal language guarantee should be assumed. Language coverage depends on the selected speech-recognition model or TTS voice. Check the model card and test with representative audio before choosing a model for users.
Will my models disappear when I restart Docker?
Not when you keep the named Hugging Face cache volume used by the supplied Compose files. Removing volumes with docker compose down -v deletes that cache.
Related GyanAangan guides
- Transcribe audio locally with faster-whisper — a CLI workflow for TXT, SRT and VTT output.
- LocalText2Voice 2.2.0 — a separate local audiobook and narration workflow.
- Open WebUI 0.13.0 — build a local AI workspace and connect tools.
- Docker Model Runner with Compose and FastAPI — another way to package a local model API.
Official documentation and project links
- Speaches installation guide
- Speech-to-text usage and OpenAI SDK examples
- Text-to-speech usage and supported formats
- Model registry, download and cache documentation
- Configuration reference, API key and model TTL settings
- Open WebUI integration guide
- Speaches source repository and release history
- Upstream report about the bundled UI and API-key authentication
Final takeaway
Speaches is useful when you want one self-hosted endpoint for both transcription and speech generation instead of wiring separate hosted audio services into every application. Start with the CPU Compose deployment, keep the port on loopback, install only the models you need, and verify both directions with curl before integrating an SDK or UI. Once the flow works, pin the image, protect the API, and test language quality and resource use on the recordings your application will actually process.
