Spaces:
Sleeping
Sleeping
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." |