Files
Ubuntu 32b43f85bd a
2026-07-03 16:58:28 +08:00

65 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# TTS Streamer 快速启动脚本
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$PROJECT_DIR"
show_help() {
echo "🎙️ TTS Streamer - 文本转音频流"
echo ""
echo "用法:"
echo " ./start.sh convert <文件> [语言] # 转换单个文件"
echo " ./start.sh stream <文件> [端口] # 启动流服务"
echo " ./start.sh batch [文件夹] # 批量转换"
echo " ./start.sh test # 测试所有语言"
echo ""
echo "语言代码: zh(中文) en(英文) jp(日文)"
echo ""
echo "示例:"
echo " ./start.sh convert articles/hello_en.txt en"
echo " ./start.sh stream articles/hello_zh.txt 8080"
}
case "${1:-help}" in
convert)
FILE="${2:-articles/hello_en.txt}"
LANG="${3:-auto}"
python3 scripts/tts_convert.py "$FILE" --lang "$LANG"
;;
stream)
FILE="${2:-articles/hello_en.txt}"
PORT="${3:-8080}"
echo "🌐 启动流服务: $FILE"
echo "📱 访问: http://$(hostname -I | awk '{print $1}' 2>/dev/null || echo 'localhost'):$PORT/stream"
echo ""
python3 scripts/stream_server.py "$FILE" --port "$PORT"
;;
batch)
DIR="${2:-articles/}"
python3 scripts/batch_convert.py "$DIR" --output output/
;;
test)
echo "🧪 测试多语言转换..."
for file in articles/hello_*.txt; do
echo ""
echo "📝 转换: $file"
python3 scripts/tts_convert.py "$file"
done
echo ""
echo "✅ 测试完成,文件保存在 output/"
;;
help|--help|-h)
show_help
;;
*)
echo "❌ 未知命令: $1"
show_help
exit 1
;;
esac