Roni Egbu commited on
Commit
81dbe2a
Β·
1 Parent(s): 45766f9

feat: Add models setup script for ASR, TTS, and MT with system dependencies check

Browse files
Files changed (1) hide show
  1. scripts/models_setup.sh +78 -0
scripts/models_setup.sh ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Exit on error
4
+ set -e
5
+
6
+ echo "πŸ—οΈ Creating directory structure..."
7
+ PROJECT_ROOT=$(pwd)
8
+ mkdir -p ./models/asr ./models/tts ./models/mt
9
+
10
+ # --- 1. WHISPER.CPP SETUP (ASR) ---
11
+ echo "πŸ“₯ Setting up Whisper.cpp (ASR)..."
12
+ cd "$PROJECT_ROOT/models/asr"
13
+
14
+ if [ ! -d "whisper.cpp" ]; then
15
+ git clone https://github.com/ggerganov/whisper.cpp.git
16
+ fi
17
+
18
+ cd whisper.cpp
19
+ # Download the tiny model using their helper script
20
+ bash ./models/download-ggml-model.sh tiny
21
+
22
+ echo "πŸ› οΈ Building whisper.cpp..."
23
+ cmake -B build
24
+ cmake --build build -j --config Release
25
+
26
+ # Verify build
27
+ if [ -f "./build/bin/whisper-cli" ]; then
28
+ echo "βœ… Whisper.cpp built successfully."
29
+ else
30
+ echo "❌ Whisper.cpp build failed."
31
+ exit 1
32
+ fi
33
+
34
+ # --- 2. PIPER VOICES (TTS) ---
35
+ echo "πŸ“₯ Downloading Piper Voice models (TTS)..."
36
+ cd "$PROJECT_ROOT/models/tts"
37
+
38
+ # French Voice (Siwis Medium)
39
+ curl -L https://huggingface.co/rhasspy/piper-voices/resolve/main/fr/fr_FR/siwis/medium/fr_FR-siwis-medium.onnx -o fr_FR-siwis-medium.onnx
40
+ curl -L https://huggingface.co/rhasspy/piper-voices/resolve/main/fr/fr_FR/siwis/medium/fr_FR-siwis-medium.onnx.json -o fr_FR-siwis-medium.onnx.json
41
+
42
+ # English Voice (Bryce Medium)
43
+ curl -L https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/bryce/medium/en_US-bryce-medium.onnx -o en_US-bryce-medium.onnx
44
+ curl -L https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/bryce/medium/en_US-bryce-medium.onnx.json -o en_US-bryce-medium.onnx.json
45
+
46
+ # --- 3. ARGOS TRANSLATE (MT) ---
47
+ echo "πŸ€– Installing Argos Language Packs (MT)..."
48
+ # Ensure we are in the backend venv if it exists
49
+ if [ -d "$PROJECT_ROOT/backend/venv" ]; then
50
+ source "$PROJECT_ROOT/backend/venv/bin/activate"
51
+ fi
52
+
53
+ pip install argostranslate
54
+
55
+ python3 << EOF
56
+ import argostranslate.package
57
+ print("Updating Argos package index...")
58
+ argostranslate.package.update_package_index()
59
+ available = argostranslate.package.get_available_packages()
60
+
61
+ pairs = [("en", "fr"), ("fr", "en")]
62
+ for f, t in pairs:
63
+ print(f"Installing {f} -> {t}...")
64
+ pkg = next(filter(lambda x: x.from_code == f and x.to_code == t, available))
65
+ argostranslate.package.install_from_path(pkg.download())
66
+ EOF
67
+
68
+ # --- 4. SYSTEM DEPENDENCIES CHECK ---
69
+ echo "πŸ” Checking system dependencies..."
70
+ if ! command -v ffmpeg &> /dev/null; then
71
+ echo "⚠️ WARNING: FFmpeg not found. Please install it: sudo apt install ffmpeg"
72
+ else
73
+ echo "βœ… FFmpeg is installed."
74
+ fi
75
+
76
+ echo "-----------------------------------------------"
77
+ echo "βœ… Setup Complete! All models prepared."
78
+ echo "πŸš€ You can now start the backend and frontend."