feat(voice): override OpenAI voice defaults for custom Whisper proxy

feat(voice): override OpenAI voice defaults for custom Whisper proxy

Replace api_server command with entrypoint that patches Onyx voice
provider files at runtime. Required because v4.8.x UI does not allow
setting api_base/stt_model for OpenAI Whisper.

- Force chunked HTTP STT via VOICE_DISABLE_STREAMING_STT=true
- Redirect all OpenAI voice constants to aido-whisper-ch.livtec.cloud
- Add WHISPER_LANGUAGE=de env var for transcription language
This commit is contained in:
Jannic Debus 2026-10-01 22:33:30 +02:00
parent 18eb30343e
commit e6ab01f6e2

View file

@ -2,6 +2,34 @@ name: onyx
services: services:
api_server: api_server:
image: ${ONYX_BACKEND_IMAGE:-onyxdotapp/onyx-backend:${IMAGE_TAG:-latest}} image: ${ONYX_BACKEND_IMAGE:-onyxdotapp/onyx-backend:${IMAGE_TAG:-latest}}
entrypoint: >
sh -c "
# 1. Fallback in factory.py (da UI api_base/stt_model nicht speichert)
sed -i 's|api_base = provider.api_base|api_base = provider.api_base or \"https://aido-whisper-ch.livtec.cloud/v1\"|' /app/onyx/voice/factory.py
sed -i 's|stt_model = provider.stt_model|stt_model = provider.stt_model or \"whisper-1\"|' /app/onyx/voice/factory.py
# 2. Default API Base in openai.py (wirkt für TTS und interne Fallbacks)
sed -i 's|DEFAULT_OPENAI_API_BASE = \"https://api.openai.com\"|DEFAULT_OPENAI_API_BASE = \"https://aido-whisper-ch.livtec.cloud/v1\"|' /app/onyx/voice/providers/openai.py
# 3. Sicherheitshalber: Auch die hartkodierten Realtime-Modelle auf whisper-1 setzen
# (falls ein Code-Pfad doch noch Streaming versucht)
sed -i 's|OPENAI_REALTIME_SESSION_MODEL = \"gpt-realtime-1.5\"|OPENAI_REALTIME_SESSION_MODEL = \"whisper-1\"|' /app/onyx/voice/providers/openai.py
sed -i 's|OPENAI_REALTIME_STT_MODEL = \"gpt-realtime-whisper\"|OPENAI_REALTIME_STT_MODEL = \"whisper-1\"|' /app/onyx/voice/providers/openai.py
# 4. Language-Patch für den Chunked-HTTP-Pfad
# (nur ausführen, wenn transcribe existiert und noch nicht gepatcht)
if grep -q 'def transcribe' /app/onyx/voice/providers/openai.py && ! grep -q 'WHISPER_LANGUAGE' /app/onyx/voice/providers/openai.py; then
sed -i '1i import os' /app/onyx/voice/providers/openai.py
# Heuristisch: Füge language zum Payload hinzu
if grep -q 'data={' /app/onyx/voice/providers/openai.py; then
sed -i '/data={/a\\ \"language\": os.environ.get(\"WHISPER_LANGUAGE\", \"de\"),' /app/onyx/voice/providers/openai.py
elif grep -q 'json={' /app/onyx/voice/providers/openai.py; then
sed -i '/json={/a\\ \"language\": os.environ.get(\"WHISPER_LANGUAGE\", \"de\"),' /app/onyx/voice/providers/openai.py
fi
fi
exec uvicorn onyx.main:app --host 0.0.0.0 --port 8080
"
command: > command: >
/bin/sh -c "alembic upgrade head && echo \"Starting Onyx Api Server\" && /bin/sh -c "alembic upgrade head && echo \"Starting Onyx Api Server\" &&
uvicorn onyx.main:app --host 0.0.0.0 --port 8080" uvicorn onyx.main:app --host 0.0.0.0 --port 8080"
@ -43,6 +71,8 @@ services:
# Onyx Craft configuration (disabled by default, set ENABLE_CRAFT=true in .env to enable) # Onyx Craft configuration (disabled by default, set ENABLE_CRAFT=true in .env to enable)
# Use --include-craft with install script, or manually set in .env file # Use --include-craft with install script, or manually set in .env file
- ENABLE_CRAFT=${ENABLE_CRAFT:-false} - ENABLE_CRAFT=${ENABLE_CRAFT:-false}
- VOICE_DISABLE_STREAMING_STT=true
- WHISPER_LANGUAGE=de
# PRODUCTION: Uncomment the line below to use if IAM_AUTH is true and you are using iam auth for postgres # PRODUCTION: Uncomment the line below to use if IAM_AUTH is true and you are using iam auth for postgres
# volumes: # volumes:
# - ./bundle.pem:/app/bundle.pem:ro # - ./bundle.pem:/app/bundle.pem:ro