IAHispano / Applio

A simple, high-quality voice conversion tool focused on ease of use and performance
https://applio.org
MIT License
1.81k stars 292 forks source link

Threw together a Google Colab #883

Open JD-2006 opened 16 hours ago

JD-2006 commented 16 hours ago

Here is a basic colab version that creates modified install scripts. Just paste into new code cells. *** Cell 1 !git clone https://github.com/IAHispano/Applio.git %cd /content/Applio

*** Cell 2

script_content = """
#!/bin/bash
set -e  # Exit immediately if a command exits with a non-zero status

printf "\\033]0;Installer\\007"
clear
rm -f *.bat  

# Function to log messages with timestamps
log_message() {
    local msg="$1"
    echo "$(date '+%Y-%m-%d %H:%M:%S') - $msg"
}

# Function to install FFmpeg (if necessary, Colab has FFmpeg installed by default)
install_ffmpeg() {
    if ! command -v ffmpeg > /dev/null; then
        log_message "FFmpeg not found. Installing..."
        sudo apt-get update
        sudo apt-get install -y ffmpeg
    else
        log_message "FFmpeg is already installed."
    fi
}

# Function to install Python FFmpeg package
install_python_ffmpeg() {
    log_message "Installing python-ffmpeg..."
    python -m pip install python-ffmpeg
}

# Function to install PyTorch
install_pytorch() {
    log_message "Installing PyTorch..."
    python -m pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --upgrade --index-url https://download.pytorch.org/whl/cu121
}

# Function to install dependencies from requirements.txt
install_dependencies() {
    log_message "Installing dependencies..."
    if [ -f "requirements.txt" ]; then
        python -m pip install -r requirements.txt
    else
        log_message "requirements.txt not found. Please ensure it exists."
        exit 1
    fi
}

# Function to finish installation
finish() {
    log_message "Verifying installed packages..."
    if [ -f "requirements.txt" ]; then
        installed_packages=$(python -m pip freeze)
        while IFS= read -r package; do
            expr "${package}" : "^#.*" > /dev/null && continue
            package_name=$(echo "${package}" | sed 's/[<>=!].*//')
            if ! echo "${installed_packages}" | grep -q "${package_name}"; then
                log_message "${package_name} not found. Attempting to install..."
                python -m pip install --upgrade "${package}"
            fi
        done < "requirements.txt"
    else
        log_message "requirements.txt not found. Please ensure it exists."
        exit 1
    fi

    clear
    echo "Applio has been successfully installed."
    exit 0
}

# Main script execution
log_message "Detected Google Colab environment..."

install_ffmpeg
install_python_ffmpeg
install_pytorch
install_dependencies

finish
"""

# Write the content to a shell script file
with open('/content/Applio/install_applio.sh', 'w') as f:
    f.write(script_content)

print("Installation script created: /content/Applio/install_applio.sh")

*** Cell 3 !bash /content/Applio/install_applio.sh

*** Cell 4

#!/bin/bash
printf "\\033]0;Applio\\007"

# Set necessary environment variables
export PYTORCH_ENABLE_MPS_FALLBACK=1
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0

clear

# Run the application (app.py) using Python
python app.py --open --share
"""

# Write the content to the run.sh file
with open('/content/Applio/run_applio.sh', 'w') as f:
    f.write(script_content)

print("Run script created: /content/Applio/run_applio.sh")

*** Cell 5 !bash /content/Applio/run_applio.sh

blaisewf commented 16 hours ago

and why do we actually need this?