#!/bin/bash # Build script for Hugging Face Space to install VERSA during the build phase set -e # Exit immediately if a command fails echo "Starting VERSA installation for Hugging Face Space build..." # Install system dependencies (already handled by packages.txt, but double-check) echo "Checking system dependencies..." if ! command -v git &> /dev/null || ! command -v ffmpeg &> /dev/null; then echo "Some system dependencies are missing. Please check packages.txt includes: git build-essential libsndfile1 ffmpeg" exit 1 fi # Set up directory structure echo "Setting up directory structure..." VERSA_ROOT="$(pwd)/versa" DATA_DIR="$(pwd)/data" CONFIG_DIR="${DATA_DIR}/configs" UPLOAD_DIR="${DATA_DIR}/uploads" RESULTS_DIR="${DATA_DIR}/results" mkdir -p "${DATA_DIR}" "${CONFIG_DIR}" "${UPLOAD_DIR}" "${RESULTS_DIR}" # Clone VERSA repository echo "Cloning VERSA repository..." if [ -d "${VERSA_ROOT}" ]; then echo "VERSA directory already exists, updating..." cd "${VERSA_ROOT}" git pull cd .. else echo "Cloning fresh VERSA repository..." git clone https://github.com/wavlab-speech/versa.git "${VERSA_ROOT}" fi # Install VERSA echo "Installing VERSA and dependencies..." cd "${VERSA_ROOT}" pip install -e . # Install basic metric dependencies echo "Installing basic metric dependencies..." # You can add specific metric installers here if needed # For example: # cd tools/nisqa # bash install.sh # cd ../.. echo "VERSA installation completed successfully!" # Create a file to indicate successful installation touch "${VERSA_ROOT}/.installation_complete" # Return to the original directory cd .. echo "Build process completed. VERSA is ready for use in the Gradio application."