File size: 4,850 Bytes
81dbe2a
 
 
 
 
 
 
3ddcabb
 
 
 
 
 
 
 
 
 
81dbe2a
3ddcabb
81dbe2a
 
3ddcabb
 
81dbe2a
 
3ddcabb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81dbe2a
 
3ddcabb
 
 
 
 
 
 
 
 
 
 
81dbe2a
3ddcabb
 
 
 
 
 
 
 
 
 
 
81dbe2a
 
 
3ddcabb
 
 
 
 
 
 
 
 
 
81dbe2a
3ddcabb
 
81dbe2a
3ddcabb
81dbe2a
3ddcabb
81dbe2a
3ddcabb
 
 
 
 
 
 
81dbe2a
3ddcabb
81dbe2a
 
 
3ddcabb
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash

# Exit on error
set -e

echo "πŸ—οΈ  Creating directory structure..."
PROJECT_ROOT=$(pwd)
mkdir -p ./models/tts

# --- 1. PIPER TTS BINARY ---
echo "πŸ“₯ Installing Piper TTS binary..."
if ! command -v piper &> /dev/null; then
    PIPER_URL="https://github.com/rhasspy/piper/releases/download/2023.11.14-2/piper_linux_x86_64.tar.gz"
    wget -q "$PIPER_URL" -O /tmp/piper.tar.gz
    sudo tar -xzf /tmp/piper.tar.gz -C /usr/local/bin/ --strip-components=1
    rm /tmp/piper.tar.gz
    echo "βœ… Piper installed."
else
    echo "βœ… Piper already installed."
fi

# --- 2. PIPER VOICE MODELS (TTS) ---
echo "πŸ“₯ Downloading Piper voice models (low quality)..."
cd "$PROJECT_ROOT/models/tts"

# English β€” ryan low
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/ryan/low/en_US-ryan-low.onnx" \
    -O en_US-ryan-low.onnx
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/ryan/low/en_US-ryan-low.onnx.json" \
    -O en_US-ryan-low.onnx.json
echo "  βœ… English (ryan low)"

# French β€” siwis low
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/fr/fr_FR/siwis/low/fr_FR-siwis-low.onnx" \
    -O fr_FR-siwis-low.onnx
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/fr/fr_FR/siwis/low/fr_FR-siwis-low.onnx.json" \
    -O fr_FR-siwis-low.onnx.json
echo "  βœ… French (siwis low)"

# German β€” thorsten low
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/de/de_DE/thorsten/low/de_DE-thorsten-low.onnx" \
    -O de_DE-thorsten-low.onnx
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/de/de_DE/thorsten/low/de_DE-thorsten-low.onnx.json" \
    -O de_DE-thorsten-low.onnx.json
echo "  βœ… German (thorsten low)"

# Spanish β€” mls_10246 low
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/es/es_ES/mls_10246/low/es_ES-mls_10246-low.onnx" \
    -O es_ES-mls_10246-low.onnx
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/es/es_ES/mls_10246/low/es_ES-mls_10246-low.onnx.json" \
    -O es_ES-mls_10246-low.onnx.json
echo "  βœ… Spanish (mls_10246 low)"

# Chinese β€” huayan x_low (only available quality)
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/zh/zh_CN/huayan/x_low/zh_CN-huayan-x_low.onnx" \
    -O zh_CN-huayan-x_low.onnx
wget -q "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/zh/zh_CN/huayan/x_low/zh_CN-huayan-x_low.onnx.json" \
    -O zh_CN-huayan-x_low.onnx.json
echo "  βœ… Chinese (huayan x_low)"

# --- 3. PYTHON ENVIRONMENT ---
echo "🐍 Setting up Python environment..."
cd "$PROJECT_ROOT/backend"

if [ ! -d "venv" ]; then
    python3 -m venv venv
    echo "βœ… Virtual environment created."
fi

source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
echo "βœ… Python dependencies installed."

# --- 4. ARGOS TRANSLATE LANGUAGE PAIRS ---
echo "πŸ€– Installing Argos Translate language pairs..."
# Languages: English, French, German, Spanish, Chinese
# Direct pairs are installed where available.
# Pairs without a direct package (e.g. zh<->de) pivot through English at runtime.
python3 - << 'PYEOF'
import argostranslate.package

PAIRS = [
    ("en", "fr"), ("fr", "en"),
    ("en", "de"), ("de", "en"),
    ("en", "es"), ("es", "en"),
    ("en", "zh"), ("zh", "en"),
    ("fr", "de"), ("de", "fr"),
    ("fr", "es"), ("es", "fr"),
    ("de", "es"), ("es", "de"),
]

print("Updating Argos package index...")
argostranslate.package.update_package_index()
available = argostranslate.package.get_available_packages()
available_map = {(p.from_code, p.to_code): p for p in available}

for src, tgt in PAIRS:
    pkg = available_map.get((src, tgt))
    if pkg:
        print(f"  Installing {src} -> {tgt}...")
        argostranslate.package.install_from_path(pkg.download())
        print(f"  βœ… {src} -> {tgt}")
    else:
        print(f"  ⚠️  No direct package for {src} -> {tgt} (will pivot via English at runtime)")

print("Argos language packs installed.")
PYEOF

# --- 5. SYSTEM DEPENDENCIES CHECK ---
echo "πŸ” Checking system dependencies..."

if ! command -v ffmpeg &> /dev/null; then
    echo "⚠️  WARNING: FFmpeg not found. Install it with: sudo apt install ffmpeg"
else
    echo "βœ… FFmpeg found."
fi

if ! command -v wget &> /dev/null; then
    echo "⚠️  WARNING: wget not found. Install it with: sudo apt install wget"
else
    echo "βœ… wget found."
fi

echo "-----------------------------------------------"
echo "βœ… Setup complete! All models and language packs ready."
echo ""
echo "πŸš€ To start the backend:"
echo "   cd backend && source venv/bin/activate"
echo "   python3 -m app.main"
echo ""
echo "⚠️  NOTE: Whisper model (faster-whisper 'base') downloads automatically"
echo "   on first startup (~150MB). Subsequent starts use the cached version."