router: deutsche Spracherkennung mit whisper.cpp (CPU-only)
- STT-Worker (stt_worker.py): langlebiger HTTP-Service auf Port 8084 - whisper-cli als Subprozess (CPU-only, 8 Threads) - Audio-Vorbereitung via ffmpeg (WebM/Opus/M4A → 16 kHz WAV) - Nativ: WAV, MP3, OGG, FLAC - Health-Endpunkt: GET /status - Transkription: POST /transcribe (Multipart-Form-Data) - Router-Integration: - POST /v1/audio/transcriptions (OpenAI-kompatibel) - GET /v1/audio/models (whisper-1, kokoro-german) - GET /v1/audio/voices (martin, victoria) - /status mit stt-Section - model=whisper-1 akzeptiert - response_format: json, verbose_json - systemd-Service: mike-ai-whisper.service - Boot-Start, Restart on failure, journald - CPU-only, kein GPU-Lock - Deploy-Dateien aktualisiert (deploy.sh, install.sh) - Mock-STT-Worker für lokale Tests (dev/mock_stt_worker.py) - Tests ergänzt: STT Status, WAV, language=de, unbekanntes Modell, Worker down, Recovery, Audio-Modelle, Audio-Voices, STT+Qwen parallel, STT+TTS parallel - README.md: STT-Section mit Endpunkten, Benchmarks, Doku Benchmarks (CPU-only, 8 Threads): 7.3 s Audio → 8.9 s (RTF 1.22×) 30 s Audio → 16.8 s (RTF 0.56×) 50 s Audio → 18.5 s (RTF 0.37×) RAM: ~1.7 GB (Modell), Worker: ~20 MB
This commit is contained in:
+2
-1
@@ -10,8 +10,9 @@ STAGE="/tmp/ai-profile-router-$$"
|
||||
|
||||
mkdir -p "$STAGE"
|
||||
cp router/ai_profile_router.py router/image_worker.py router/tts_worker.py \
|
||||
router/stt_worker.py \
|
||||
deploy/install.sh deploy/mike-ai-profile-router.service \
|
||||
deploy/mike-ai-kokoro.service "$STAGE/"
|
||||
deploy/mike-ai-kokoro.service deploy/mike-ai-whisper.service "$STAGE/"
|
||||
|
||||
echo "== Übertrage Dateien nach ${TARGET}:/tmp/ai-profile-router/"
|
||||
ssh -i "$SSH_KEY" "$TARGET" 'mkdir -p /tmp/ai-profile-router'
|
||||
|
||||
+11
-1
@@ -10,6 +10,7 @@ DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
INSTALL_DIR=/opt/mike-ai/ai-profile-router
|
||||
SERVICE=mike-ai-profile-router.service
|
||||
KOKORO_SERVICE=mike-ai-kokoro.service
|
||||
WHISPER_SERVICE=mike-ai-whisper.service
|
||||
OLD_SERVICE=mike-ai-local-llm-router.service
|
||||
OLD_DIR=/opt/mike-ai/local-llm-router
|
||||
BACKUP_DIR=/opt/mike-ai/.backup-ai-profile-router-$(date +%Y%m%d-%H%M%S)
|
||||
@@ -40,8 +41,10 @@ mkdir -p "$INSTALL_DIR" "$IMAGE_DIR"
|
||||
install -m 0755 "$DIR/ai_profile_router.py" "$INSTALL_DIR/ai_profile_router.py"
|
||||
install -m 0755 "$DIR/image_worker.py" "$INSTALL_DIR/image_worker.py"
|
||||
install -m 0755 "$DIR/tts_worker.py" "$INSTALL_DIR/tts_worker.py"
|
||||
install -m 0755 "$DIR/stt_worker.py" "$INSTALL_DIR/stt_worker.py"
|
||||
install -m 0644 "$DIR/${SERVICE}" "/etc/systemd/system/${SERVICE}"
|
||||
install -m 0644 "$DIR/${KOKORO_SERVICE}" "/etc/systemd/system/${KOKORO_SERVICE}"
|
||||
install -m 0644 "$DIR/${WHISPER_SERVICE}" "/etc/systemd/system/${WHISPER_SERVICE}"
|
||||
|
||||
# --- 3. Python-Venv mit Bild-Abhängigkeiten ---------------------------------
|
||||
if [ ! -x "$VENV/bin/python" ]; then
|
||||
@@ -134,8 +137,9 @@ fi
|
||||
|
||||
# --- 6. Services aktivieren und starten ---------------------------------------
|
||||
systemctl daemon-reload
|
||||
systemctl enable "$SERVICE" "$KOKORO_SERVICE"
|
||||
systemctl enable "$SERVICE" "$KOKORO_SERVICE" "$WHISPER_SERVICE"
|
||||
systemctl restart "$KOKORO_SERVICE"
|
||||
systemctl restart "$WHISPER_SERVICE"
|
||||
systemctl restart "$SERVICE"
|
||||
|
||||
# --- 7. Verifikation ----------------------------------------------------------
|
||||
@@ -152,5 +156,11 @@ if ! systemctl is-active --quiet "$KOKORO_SERVICE"; then
|
||||
exit 1
|
||||
fi
|
||||
echo "-- Kokoro-Service läuft"
|
||||
if ! systemctl is-active --quiet "$WHISPER_SERVICE"; then
|
||||
echo "-- FEHLER: Whisper-Service läuft nicht" >&2
|
||||
journalctl -u "$WHISPER_SERVICE" -n 20 --no-pager >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "-- Whisper-Service läuft"
|
||||
curl -sf "http://127.0.0.1:8081/status" | python3 -m json.tool
|
||||
echo "== Fertig =="
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
[Unit]
|
||||
Description=Whisper STT Worker (deutsche Spracherkennung, CPU-only)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/mike-ai/ai-profile-router
|
||||
Environment=WHISPER_HOST=127.0.0.1
|
||||
Environment=WHISPER_PORT=8084
|
||||
Environment=WHISPER_CLI=/opt/mike-ai/whisper.cpp/build-cpu/bin/whisper-cli
|
||||
Environment=WHISPER_MODEL=/opt/mike-ai/models/whisper/ggml-large-v3-turbo.bin
|
||||
Environment=WHISPER_THREADS=8
|
||||
Environment=WHISPER_LANGUAGE=de
|
||||
Environment=FFMPEG_BIN=/usr/bin/ffmpeg
|
||||
Environment=LOG_LEVEL=INFO
|
||||
ExecStart=/usr/bin/python3 /opt/mike-ai/ai-profile-router/stt_worker.py
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
# CPU-only: keine GPU-Bindung, keine VRAM-Belegung
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user