Kleineres Modell

This commit is contained in:
2026-06-19 17:22:28 +02:00
parent a5230964cb
commit 404c632cfc
20 changed files with 66 additions and 60 deletions

24
scripts/clone_model.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")/.."
case "${1:-}" in
load|start)
docker compose --profile clone up -d qwen3-tts-clone
;;
unload|stop)
docker compose --profile clone stop qwen3-tts-clone >/dev/null
docker compose --profile clone rm -f qwen3-tts-clone >/dev/null
;;
status)
docker ps --filter "name=qwen3-tts-clone" --format '{{.Names}} {{.Status}} {{.Ports}}'
;;
logs)
docker logs -f qwen3-tts-clone
;;
*)
echo "Usage: $0 {load|unload|status|logs}" >&2
echo "Set QWEN3_TTS_CLONE_MODEL=<model-id> before load if needed." >&2
exit 2
;;
esac

View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
MODEL="${QWEN3_TTS_BASE_MODEL:-Qwen/Qwen3-TTS-12Hz-1.7B-Base}"
CACHE_ROOT="/home/guru/vllm/data/root"
mkdir -p "$CACHE_ROOT/.cache/huggingface"
printf "Lade %s in gemeinsamen Container-Cache...\n" "$MODEL"
docker run --rm \
-e HF_HOME=/root/.cache/huggingface \
-v "$CACHE_ROOT:/root" \
vllm/vllm-omni:latest-aarch64 \
python3 -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='$MODEL')"
printf "Fertig. Danach: ./start_dialog_tts.sh\n"

4
scripts/start.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"
exec ./start_tts.sh "$@"

45
scripts/start_clone.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")/.."
HEALTH_URL="http://localhost:8091/health"
MAX_WAIT="${MAX_WAIT:-180}"
[ -f .env ] && source .env
MODEL="${QWEN3_TTS_CLONE_MODEL:-Qwen/Qwen3-TTS-12Hz-1.7B-Base}"
t0=$SECONDS
printf "TTS-Container stoppt..."
docker compose stop qwen3-tts >/dev/null 2>&1 || true
docker compose rm -f qwen3-tts >/dev/null 2>&1 || true
printf " [%ds]
" $(( SECONDS - t0 ))
printf "Clone-Container startet..."
docker compose --profile clone up -d qwen3-tts-clone >/tmp/qwen3-tts-clone-compose.log 2>&1
printf " [%ds]
" $(( SECONDS - t0 ))
printf " Modell %s
" "$MODEL"
printf " API http://localhost:8091
"
while (( SECONDS - t0 < MAX_WAIT )); do
if curl -sf "$HEALTH_URL" >/dev/null 2>&1; then
printf "✓ Clone bereit: http://localhost:8091 [%ds]
" $(( SECONDS - t0 ))
exit 0
fi
if ! docker ps --filter "name=qwen3-tts-clone" --filter "status=running" -q | grep -q .; then
printf "✗ Clone-Container abgestürzt. Logs:
" >&2
docker logs --tail=40 qwen3-tts-clone 2>&1 >&2 || true
exit 1
fi
sleep 2
done
printf "✗ Timeout nach %ss. Logs: docker logs qwen3-tts-clone
" "$MAX_WAIT" >&2
exit 1

5
scripts/start_custom_tts.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
export QWEN3_TTS_MODEL="${QWEN3_TTS_MODEL:-Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice}"
exec ./start_tts.sh

5
scripts/start_dialog_tts.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
export QWEN3_TTS_MODEL="${QWEN3_TTS_MODEL:-Qwen/Qwen3-TTS-12Hz-1.7B-Base}"
exec ./start_tts.sh

80
scripts/start_tts.sh Executable file
View File

@@ -0,0 +1,80 @@
#!/bin/bash
set -e
cd "$(dirname "$0")/.."
HEALTH_URL="http://localhost:8091/health"
MAX_WAIT=180
# .env aus dem Projektroot laden (nur falls Variable nicht schon im Shell-Env gesetzt)
[ -f .env ] && source .env
MODEL="${QWEN3_TTS_MODEL:-Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice}"
strip_ansi() { sed 's/\x1b\[[0-9;]*[mK]//g'; }
t0=$SECONDS
# --- Gegenseitigen Service stoppen ---
printf "Clone-Container stoppt..."
docker compose --profile clone stop qwen3-tts-clone >/dev/null 2>&1 || true
docker compose --profile clone rm -f qwen3-tts-clone >/dev/null 2>&1 || true
printf " [%ds]
" $(( SECONDS - t0 ))
# --- Container starten ---
printf "TTS-Container startet..."
docker compose up -d qwen3-tts &>/tmp/qwen3-tts-compose.log
printf " [%ds]\n" $(( SECONDS - t0 ))
printf " Modell %s\n\n" "$MODEL"
# --- Log-Events im Hintergrund parsen und ausgeben ---
docker logs -f qwen3-tts 2>&1 | strip_ansi | while IFS= read -r line; do
case "$line" in
*"Stage 0 engine launch started"*)
printf " Stage 0 Talker LLM wird geladen\n" ;;
*"Initializing a V1 LLM engine"*)
printf " Stage 0 Engine initialisiert\n" ;;
*"Loading weights"*)
printf " Stage 0 Modell-Gewichte werden geladen...\n" ;;
*"Loading model weights took"*)
took=$(echo "$line" | grep -oP '\d+\.\d+s' | head -1)
printf " Stage 0 Gewichte geladen (%s)\n" "$took" ;;
*"Stage 1 engine launch started"*)
printf " Stage 1 Code2Wav Decoder wird geladen\n" ;;
*"Graph capturing finished"*)
printf " CUDA Graphen kompiliert\n" ;;
*"Application startup complete"*)
printf " Server FastAPI bereit\n" ;;
*"Uvicorn running on"*)
printf " Server HTTP läuft auf Port 8091\n" ;;
*"warmup] Server gesund"*)
printf " Warmup Aufwärm-Request läuft (kompiliert/lädt Graphen)...\n" ;;
*"warmup] fertig"*)
took=$(echo "$line" | grep -oP '\d+s' | head -1)
printf " Warmup Server ist heiß (%s)\n" "$took" ;;
*"ERROR"*|*"ValueError"*)
msg=$(echo "$line" | grep -oP '(ERROR|ValueError).*' | head -1)
printf " [!] %s\n" "${msg:0:100}" ;;
esac
done &
LOG_PID=$!
# --- Health-Check-Schleife ---
while (( SECONDS - t0 < MAX_WAIT )); do
if curl -sf "$HEALTH_URL" >/dev/null 2>&1; then
kill "$LOG_PID" 2>/dev/null
wait "$LOG_PID" 2>/dev/null || true
printf "\n✓ Bereit: API http://localhost:8091 UI http://localhost:8092 WS-Log ws://localhost:8094/v1/audio/speech/stream [%ds]\n" $(( SECONDS - t0 ))
exit 0
fi
# Abbruch wenn Container schon gestoppt ist
if ! docker ps --filter "name=qwen3-tts" --filter "status=running" -q | grep -q .; then
kill "$LOG_PID" 2>/dev/null
printf "\n✗ Container abgestürzt. Logs:\n"
docker logs --tail=20 qwen3-tts 2>&1 | strip_ansi | grep -E "ERROR|ValueError|Exception" | head -5
exit 1
fi
sleep 2
done
kill "$LOG_PID" 2>/dev/null
printf "\n✗ Timeout nach %ds. Logs: docker logs qwen3-tts\n" "$MAX_WAIT" >&2
exit 1

8
scripts/stop_clone.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")/.."
docker compose --profile clone stop qwen3-tts-clone >/dev/null 2>&1 || true
docker compose --profile clone rm -f qwen3-tts-clone >/dev/null 2>&1 || true
printf "✓ Clone-Service gestoppt
"

8
scripts/stop_tts.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")/.."
docker compose stop qwen3-tts >/dev/null 2>&1 || true
docker compose rm -f qwen3-tts >/dev/null 2>&1 || true
printf "✓ TTS/UI gestoppt
"