Files
voice.sori.studio/scripts/select_model.sh
zenn 7101fdcd65 Initial commit: Korean voice-cloning TTS prototype
FastAPI backend, web UI, CosyVoice3/F5-TTS setup scripts, and handoff docs for GPU PC continuation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 13:36:37 +09:00

35 lines
904 B
Bash
Executable File

#!/usr/bin/env bash
# 최종 모델 선택을 .env 와 config에 반영
set -euo pipefail
MODEL="${1:-}"
if [[ -z "$MODEL" || ! "$MODEL" =~ ^(cosyvoice|f5_tts)$ ]]; then
echo "Usage: $0 cosyvoice|f5_tts"
exit 1
fi
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
ENV_FILE="$ROOT/.env"
if [[ -f "$ENV_FILE" ]]; then
if grep -q '^TTS_MODEL=' "$ENV_FILE"; then
sed -i.bak "s/^TTS_MODEL=.*/TTS_MODEL=$MODEL/" "$ENV_FILE"
rm -f "$ENV_FILE.bak"
else
echo "TTS_MODEL=$MODEL" >> "$ENV_FILE"
fi
else
cp "$ROOT/.env.example" "$ENV_FILE"
echo "TTS_MODEL=$MODEL" >> "$ENV_FILE"
fi
python3 - <<PY
import json
from pathlib import Path
p = Path("$ROOT/config/model_choice.json")
data = json.loads(p.read_text(encoding="utf-8"))
data["selected_model"] = "$MODEL"
p.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print("selected_model=$MODEL")
PY