melakio commited on
Commit
4e2fcb6
Β·
verified Β·
1 Parent(s): 430666c

Upload start_tts.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. start_tts.sh +56 -0
start_tts.sh ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # ─────────────────────────────────────────────────────────────────────────────
3
+ # Arabic AI TTS Server Launcher
4
+ # Starts the FastPitch + HiFi-GAN neural TTS server on port 3003
5
+ # ─────────────────────────────────────────────────────────────────────────────
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ VENV_PYTHON="$SCRIPT_DIR/tts_venv/bin/python3"
9
+ TTS_SCRIPT="$SCRIPT_DIR/tts_server.py"
10
+
11
+ # Check venv exists
12
+ if [ ! -f "$VENV_PYTHON" ]; then
13
+ echo "❌ Error: Python venv not found at $SCRIPT_DIR/tts_venv"
14
+ echo " Run the setup first: python3 -m venv tts_venv && tts_venv/bin/pip install git+https://github.com/nipponjo/tts_arabic.git flask"
15
+ exit 1
16
+ fi
17
+
18
+ # Kill any existing instance on port 3003
19
+ EXISTING_PID=$(lsof -ti:3003 2>/dev/null)
20
+ if [ -n "$EXISTING_PID" ]; then
21
+ echo "πŸ”„ Stopping existing TTS server (PID: $EXISTING_PID)..."
22
+ kill "$EXISTING_PID" 2>/dev/null
23
+ sleep 1
24
+ fi
25
+
26
+ echo "πŸš€ Starting Arabic AI TTS Server (FastPitch + HiFi-GAN)..."
27
+ echo " Port: 3003"
28
+ echo " Engine: nipponjo/tts_arabic (ONNX)"
29
+ echo " Test: curl 'http://localhost:3003/health'"
30
+ echo ""
31
+
32
+ # Start in background with logs
33
+ "$VENV_PYTHON" "$TTS_SCRIPT" &
34
+ TTS_PID=$!
35
+
36
+ echo "βœ… TTS Server started (PID: $TTS_PID)"
37
+ echo " Waiting for warm-up (~10 seconds for model loading)..."
38
+
39
+ # Wait for server to be ready
40
+ for i in {1..30}; do
41
+ sleep 1
42
+ if curl -s http://localhost:3003/health > /dev/null 2>&1; then
43
+ echo "βœ… TTS Server ready!"
44
+ echo ""
45
+ echo " Endpoints:"
46
+ echo " GET http://localhost:3003/tts?text=<arabic>"
47
+ echo " GET http://localhost:3003/tts/preprocess?text=<arabic>"
48
+ echo " GET http://localhost:3003/health"
49
+ echo " GET http://localhost:3003/tts/cache/info"
50
+ break
51
+ fi
52
+ printf "."
53
+ done
54
+
55
+ echo ""
56
+ echo "πŸ’‘ To stop: kill $TTS_PID OR kill \$(lsof -ti:3003)"