TranscriptStation/install.sh

143 lines
6.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# install.sh Installation de TranscribeStation
# Testé sur Debian 12 (Bookworm) et Debian 13 (Trixie)
set -euo pipefail
# ─── Couleurs terminal ────────────────────────────────────────────────────────
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
CYAN='\033[0;36m'; BOLD='\033[1m'; NC='\033[0m'
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
success() { echo -e "${GREEN}[OK]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERR]${NC} $*" >&2; exit 1; }
step() { echo -e "\n${BOLD}$*${NC}"; }
echo -e "${BOLD}"
echo "╔══════════════════════════════════════════════╗"
echo "║ TranscribeStation Installation ║"
echo "║ Debian 12/13 · Python · Qt6 ║"
echo "╚══════════════════════════════════════════════╝"
echo -e "${NC}"
# ─── Vérifications préliminaires ─────────────────────────────────────────────
if [[ $EUID -eq 0 ]]; then
error "Ne pas lancer ce script en root. Utilisez votre compte normal."
fi
command -v python3 >/dev/null 2>&1 || error "python3 introuvable."
PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
info "Python détecté : $PYTHON_VERSION"
# ─── Étape 1 : Dépendances système ───────────────────────────────────────────
step "[1/6] Installation des dépendances système..."
sudo apt-get update -qq
sudo apt-get install -y \
python3 python3-pip python3-venv \
libhidapi-dev libhidapi-hidraw0 libusb-1.0-0 \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
fonts-noto-color-emoji \
2>&1 | grep -E "^(Inst|Conf|E:)" || true
success "Dépendances système installées."
# ─── Étape 2 : Environnement virtuel Python ───────────────────────────────────
step "[2/6] Création de l'environnement virtuel..."
if [ -d ".venv" ]; then
warn "Environnement .venv existant détecté — réutilisation."
else
python3 -m venv .venv
success "Environnement virtuel créé dans .venv/"
fi
source .venv/bin/activate
# ─── Étape 3 : Mise à jour de pip ────────────────────────────────────────────
step "[3/6] Mise à jour de pip..."
pip install --upgrade pip --quiet
success "pip mis à jour : $(pip --version | awk '{print $2}')"
# ─── Étape 4 : Dépendances Python ────────────────────────────────────────────
step "[4/6] Installation des dépendances Python..."
info "Installation de PySide6 (interface + lecteur audio)..."
pip install "PySide6>=6.5.0" --quiet
success "PySide6 $(pip show PySide6 | awk '/^Version/{print $2}')"
info "Installation de numpy + soundfile (affichage waveform)..."
pip install "numpy>=1.24.0" "soundfile>=0.12.0" --quiet
success "numpy $(pip show numpy | awk '/^Version/{print $2}') soundfile $(pip show soundfile | awk '/^Version/{print $2}')"
info "Installation de hid (support pédalier USB HID)..."
if pip install "hid>=1.0.5" --quiet 2>/dev/null; then
success "hid $(pip show hid | awk '/^Version/{print $2}')"
else
warn "Le paquet 'hid' n'a pas pu être installé automatiquement."
warn "Tentative via hidapi..."
if pip install "hidapi>=0.14.0" --quiet 2>/dev/null; then
success "hidapi installé (alias hid)."
else
warn "Support pédalier désactivé. Pour l'activer plus tard :"
warn " pip install hid ou pip install hidapi"
fi
fi
info "Vérification des imports Python..."
python3 - << 'PYCHECK'
import importlib
for pkg, mod in [("PySide6","PySide6.QtWidgets"),("numpy","numpy"),
("soundfile","soundfile"),("hid","hid")]:
try:
importlib.import_module(mod)
print(f" \u2705 {pkg}")
except ImportError:
print(f" \u26a0\ufe0f {pkg} (non disponible)")
PYCHECK
# ─── Étape 5 : Règle udev pédalier Olympus ───────────────────────────────────
step "[5/6] Configuration udev pour le pédalier Olympus..."
UDEV_FILE="/etc/udev/rules.d/99-olympus-pedal.rules"
RULE='SUBSYSTEM=="hidraw", ATTRS{idVendor}=="07b4", MODE="0666", GROUP="plugdev"'
if [ -f "$UDEV_FILE" ]; then
warn "Règle udev déjà présente : $UDEV_FILE"
else
echo "$RULE" | sudo tee "$UDEV_FILE" > /dev/null
sudo udevadm control --reload-rules
sudo udevadm trigger
success "Règle udev créée : $UDEV_FILE"
fi
if groups "$USER" | grep -q plugdev; then
success "Utilisateur '$USER' déjà dans le groupe 'plugdev'."
else
sudo usermod -aG plugdev "$USER"
success "Utilisateur '$USER' ajouté au groupe 'plugdev'."
warn "Déconnectez-vous et reconnectez-vous pour activer le groupe."
fi
# ─── Étape 6 : Création du lanceur ───────────────────────────────────────────
step "[6/6] Création du script de lancement..."
cat > launch.sh << 'LAUNCHEOF'
#!/usr/bin/env bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/.venv/bin/activate"
exec python "$SCRIPT_DIR/transcribe_station.py" "$@"
LAUNCHEOF
chmod +x launch.sh
success "Script de lancement créé : ./launch.sh"
# ─── Résumé ──────────────────────────────────────────────────────────────────
echo ""
echo -e "${GREEN}${BOLD}Installation terminée !${NC}"
echo ""
echo -e " Lancer l'application :"
echo -e " ${CYAN}./launch.sh${NC}"
echo -e " ou"
echo -e " ${CYAN}source .venv/bin/activate && python transcribe_station.py${NC}"
echo ""
echo -e " ${YELLOW}Rappel :${NC} si vous avez été ajouté au groupe 'plugdev',"
echo -e " déconnectez-vous/reconnectez-vous avant de brancher le pédalier."
echo ""