-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPolGen-Installer.sh
138 lines (122 loc) · 4.19 KB
/
PolGen-Installer.sh
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
134
135
136
137
138
#!/bin/bash
set -e
echo "Welcome to the PolGen Installer!"
echo
PRINCIPAL=$(pwd)
MINICONDA_DIR="$HOME/miniconda3"
ENV_DIR="$PRINCIPAL/env"
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-py310_24.11.1-0-Linux-x86_64.sh"
CONDA_EXE="$MINICONDA_DIR/bin/conda"
install_miniconda() {
if [ -d "$MINICONDA_DIR" ]; then
echo "Miniconda already installed. Skipping installation."
return
fi
echo "Miniconda not found. Starting download and installation..."
wget -O miniconda.sh "$MINICONDA_URL"
if [ ! -f "miniconda.sh" ]; then
echo "Download failed. Please check your internet connection and try again."
exit 1
fi
bash miniconda.sh -b -p "$MINICONDA_DIR"
if [ $? -ne 0 ]; then
echo "Miniconda installation failed."
exit 1
fi
rm miniconda.sh
echo "Miniconda installation complete."
echo
}
create_conda_env() {
echo "Creating Conda environment..."
"$MINICONDA_DIR/bin/conda" create --yes --prefix "$ENV_DIR" python=3.10
if [ $? -ne 0 ]; then
echo "An error occurred during environment creation."
exit 1
fi
if [ -f "$ENV_DIR/bin/python" ]; then
echo "Installing specific pip version..."
"$ENV_DIR/bin/python" -m pip install "pip<24.1"
if [ $? -ne 0 ]; then
echo "Pip installation failed."
exit 1
fi
echo "Pip installation complete."
echo
fi
}
install_dependencies() {
echo "Installing dependencies..."
source "$MINICONDA_DIR/etc/profile.d/conda.sh"
conda activate "$ENV_DIR"
pip install --upgrade setuptools
pip install -r "$PRINCIPAL/requirements.txt"
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --upgrade --index-url https://download.pytorch.org/whl/cu121
conda deactivate
echo "Dependencies installation complete."
echo
}
install_ffmpeg() {
if command -v brew > /dev/null; then
echo "Installing FFmpeg using Homebrew on macOS..."
brew install ffmpeg
elif command -v apt > /dev/null; then
echo "Installing FFmpeg using apt..."
sudo apt update && sudo apt install -y ffmpeg
elif command -v pacman > /dev/null; then
echo "Installing FFmpeg using pacman..."
sudo pacman -Syu --noconfirm ffmpeg
elif command -v dnf > /dev/null; then
echo "Installing FFmpeg using dnf..."
sudo dnf install -y ffmpeg --allowerasing || install_ffmpeg_flatpak
else
echo "Unsupported distribution for FFmpeg installation. Trying Flatpak..."
install_ffmpeg_flatpak
fi
}
install_ffmpeg_flatpak() {
if command -v flatpak > /dev/null; then
echo "Installing FFmpeg using Flatpak..."
flatpak install --user -y flathub org.freedesktop.Platform.ffmpeg
else
echo "Flatpak is not installed. Installing Flatpak..."
if command -v apt > /dev/null; then
sudo apt install -y flatpak
elif command -v pacman > /dev/null; then
sudo pacman -Syu --noconfirm flatpak
elif command -v dnf > /dev/null; then
sudo dnf install -y flatpak
elif command -v brew > /dev/null; then
brew install flatpak
else
echo "Unable to install Flatpak automatically. Please install Flatpak and try again."
exit 1
fi
flatpak install --user -y flathub org.freedesktop.Platform.ffmpeg
fi
}
installing_necessary_models() {
echo "Checking for required models..."
HUBERT_BASE="$PRINCIPAL/rvc/models/embedders/hubert_base.pt"
FCPE="$PRINCIPAL/rvc/models/predictors/fcpe.pt"
RMVPE="$PRINCIPAL/rvc/models/predictors/rmvpe.pt"
if [ -f "$HUBERT_BASE" ] && [ -f "$FCPE" ] && [ -f "$RMVPE" ]; then
echo "All required models are installed."
else
echo "Required models were not found. Installing models..."
"$ENV_DIR/bin/python" download_models.py
if [ $? -ne 0 ]; then
echo "Model installation failed."
exit 1
fi
fi
echo
}
install_miniconda
create_conda_env
install_dependencies
install_ffmpeg
installing_necessary_models
echo "PolGen has been installed successfully!"
echo "To start PolGen, please run './PolGen.sh'."
echo