Enhance setup scripts for TTS environment initialization

- Updated setup.ps1 and setup.sh to check for and install the 'uv' package manager if not already present.
- Modified virtual environment creation to use 'uv' for consistency across platforms.
- Improved activation instructions for the virtual environment in both scripts.
- Added FFmpeg installation for Windows and system dependencies for Linux and macOS to ensure all necessary tools are available for TTS functionality.
- Streamlined dependency installation process to utilize 'uv' for package management.
This commit is contained in:
Pierre Bruno
2025-01-24 20:02:11 +01:00
parent 1fc7602e1b
commit 23f0ffb7da
2 changed files with 49 additions and 22 deletions

View File

@@ -1,22 +1,32 @@
# Setup script for Windows
Write-Host "Setting up Kokoro TTS Local..."
# Check if Python is installed
if (!(Get-Command python -ErrorAction SilentlyContinue)) {
Write-Host "Error: Python is not installed. Please install Python 3.8 or higher."
exit 1
# Check if uv is installed
$uvExists = Get-Command uv -ErrorAction SilentlyContinue
if (-not $uvExists) {
Write-Host "Installing uv package manager..."
iwr -useb https://astral.sh/uv/install.ps1 | iex
}
# Create and activate virtual environment
Write-Host "Creating virtual environment..."
python -m venv venv
.\venv\Scripts\Activate
# Create virtual environment if it doesn't exist
if (-not (Test-Path "venv")) {
Write-Host "Creating virtual environment..."
uv venv
}
# Upgrade pip
python -m pip install --upgrade pip
# Activate virtual environment
Write-Host "Activating virtual environment..."
.\venv\Scripts\Activate.ps1
# Install dependencies
# Install dependencies using uv
Write-Host "Installing dependencies..."
pip install -r requirements.txt
uv pip install -r requirements.txt
Write-Host "Setup complete! You can now run: python tts_demo.py"
# Install FFmpeg if not already installed (using winget)
$ffmpegExists = Get-Command ffmpeg -ErrorAction SilentlyContinue
if (-not $ffmpegExists) {
Write-Host "Installing FFmpeg..."
winget install -e --id Gyan.FFmpeg
}
Write-Host "Setup complete! Run '.\venv\Scripts\Activate.ps1' to activate the virtual environment."

View File

@@ -8,16 +8,33 @@ if ! command -v python3 &> /dev/null; then
exit 1
fi
# Create and activate virtual environment
echo "Creating virtual environment..."
python3 -m venv venv
# Install uv if not already installed
if ! command -v uv &> /dev/null; then
echo "Installing uv package manager..."
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
uv venv
fi
# Activate virtual environment
source venv/bin/activate
# Upgrade pip
python -m pip install --upgrade pip
# Install dependencies
# Install dependencies using uv
echo "Installing dependencies..."
pip install -r requirements.txt
uv pip install -r requirements.txt
echo "Setup complete! You can now run: python tts_demo.py"
# Install system dependencies if needed
if [ "$(uname)" == "Linux" ]; then
echo "Installing system dependencies..."
sudo apt-get update
sudo apt-get install -y espeak-ng ffmpeg
elif [ "$(uname)" == "Darwin" ]; then
echo "Installing system dependencies..."
brew install espeak-ng ffmpeg
fi
echo "Setup complete! Run 'source venv/bin/activate' to activate the virtual environment."