Self-hosted STT/TTS
1.1K
Self‑hosted audio microservice providing:
This service is called by the web app for microphone transcription and answer playback.
docker compose -f docker/docker-compose.yml build
docker compose -f docker/docker-compose.yml up -d
Add at least one Piper voice (see Voices below), then verify:
curl -s http://localhost:8001/tts/voices | jq
GET / → { service, stt_model, voices }POST /stt (multipart)
audio: audio file (webm/ogg/wav)language: optional (auto, en, de, tr, …){ text, language, language_probability }GET /tts/voices → { voices: ["de_DE-thorsten-low.onnx", ...] }POST /tts (form)
text, voice (filename from /voices)audio/wav streamPOST /tts/voice_from_url (form)
url (direct .onnx), config_url (matching .onnx.json, optional)/voicesPOST /tts/voice_upload (multipart)
onnx (file), config (file) → saves both into /voicesPiper requires a voice pair: voice.onnx and voice.onnx.json.
Options to install voices on the host:
https://huggingface.co/datasets/rhasspy/piper-voices/resolve/main/de/de_DE/thorsten-low/de_DE-thorsten-low.onnx
https://huggingface.co/datasets/rhasspy/piper-voices/resolve/main/de/de_DE/thorsten-low/de_DE-thorsten-low.onnx.json
Compose mounts ./voices:/voices by default. Make sure your files are under ./voices.
If you downloaded to docker/voices, either:
mkdir -p voices && mv docker/voices/* voices/ && docker compose -f docker/docker-compose.yml restartdocker/docker-compose.yml to ./docker/voices:/voices and restart.Environment variables (see docker/docker-compose.yml):
STT_MODEL (default small) – faster‑whisper model idSTT_COMPUTE_TYPE (default int8) – e.g. int8, int8_float16, int16, float16STT_LANGUAGE (default auto) – language hint for STTThe image enables CORS for browser access.
curl -s -X POST http://localhost:8001/stt \
-F language=de \
-F audio=@/path/to/sample.wav
curl -s -X POST http://localhost:8001/tts \
-F text='Hallo! Ich helfe dir bei Mathe.' \
-F voice=de_DE-thorsten-low.onnx \
-o out.wav && \
ffplay -nodisp -autoexit out.wav
docker build -t YOUR_DH_USER/mathassist-audio:latest -f docker/Dockerfile .
docker login
docker push YOUR_DH_USER/mathassist-audio:latest
docker buildx create --use
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t YOUR_DH_USER/mathassist-audio:latest \
-f docker/Dockerfile --push .
For README sync and automated pushes, consider a GitHub Actions workflow using docker/build-push-action and peter-evans/dockerhub-description.
/tts/voices is empty
./voices by default). Restart the container after adding files.voice exists in /voices and the .onnx.json is present.Content type
Image
Digest
sha256:59450fa6b…
Size
412.9 MB
Last updated
11 months ago
docker pull d8devs/mathassist-audio