1
0
mirror of synced 2024-12-18 02:16:08 +01:00
Retrieval-based-Voice-Conve.../run.sh

63 lines
1.8 KiB
Bash
Raw Normal View History

#!/bin/sh
if [ "$(uname)" = "Darwin" ]; then
# macOS specific env:
export PYTORCH_ENABLE_MPS_FALLBACK=1
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
elif [ "$(uname)" != "Linux" ]; then
echo "Unsupported operating system."
exit 1
fi
2023-08-26 19:21:18 +02:00
if [ -d ".venv" ]; then
echo "Activate venv..."
. .venv/bin/activate
2023-08-26 19:21:18 +02:00
else
echo "Create venv..."
requirements_file="requirements.txt"
# Check if Python 3.8 is installed
2024-01-25 13:04:29 +01:00
if ! command -v python3.8 >/dev/null 2>&1 || pyenv versions --bare | grep -q "3.8"; then
2023-08-26 19:21:18 +02:00
echo "Python 3 not found. Attempting to install 3.8..."
if [ "$(uname)" = "Darwin" ] && command -v brew >/dev/null 2>&1; then
2023-08-26 19:21:18 +02:00
brew install python@3.8
elif [ "$(uname)" = "Linux" ] && command -v apt-get >/dev/null 2>&1; then
2023-08-26 19:21:18 +02:00
sudo apt-get update
sudo apt-get install python3.8
else
echo "Please install Python 3.8 manually."
exit 1
fi
fi
2024-01-25 13:04:29 +01:00
python3.8 -m venv .venv
. .venv/bin/activate
2023-08-26 19:21:18 +02:00
# Check if required packages are installed and install them if not
if [ -f "${requirements_file}" ]; then
2024-01-25 13:04:29 +01:00
installed_packages=$(python3.8 -m pip freeze)
2023-08-26 19:21:18 +02:00
while IFS= read -r package; do
expr "${package}" : "^#.*" > /dev/null && continue
2023-08-26 19:21:18 +02:00
package_name=$(echo "${package}" | sed 's/[<>=!].*//')
if ! echo "${installed_packages}" | grep -q "${package_name}"; then
echo "${package_name} not found. Attempting to install..."
2024-01-25 13:04:29 +01:00
python3.8 -m pip install --upgrade "${package}"
2023-08-26 19:21:18 +02:00
fi
done < "${requirements_file}"
else
2023-08-26 19:21:18 +02:00
echo "${requirements_file} not found. Please ensure the requirements file with required packages exists."
exit 1
fi
fi
2023-08-26 19:21:18 +02:00
# Download models
chmod +x tools/dlmodels.sh
2023-08-26 19:21:18 +02:00
./tools/dlmodels.sh
if [ $? -ne 0 ]; then
2023-09-02 07:53:56 +02:00
exit 1
fi
# Run the main script
2024-01-25 13:04:29 +01:00
python3.8 infer-web.py --pycmd python3.8