# VoiceGrab — Windows build script # Usage (from project root): powershell -ExecutionPolicy Bypass -File installer\build_win.ps1 [-BuildAI] # -BuildAI also bundle the optional AI voice separation (torch+demucs; # exe grows by ~2 GB). Core users don't need it. param( [switch]$BuildAI ) $ErrorActionPreference = "Stop" $root = Split-Path -Parent $PSScriptRoot Set-Location $root # 1. Ensure a venv with deps if (-not (Test-Path ".venv\Scripts\python.exe")) { python -m venv .venv } & ".venv\Scripts\python.exe" -m pip install --upgrade pip & ".venv\Scripts\python.exe" -m pip install -r requirements.txt pyinstaller if ($BuildAI) { Write-Host "Building with AI voice separation (torch+demucs)…" & ".venv\Scripts\python.exe" -m pip install -r requirements-ai.txt } # AI-mode collection flags (no-op when not building the AI pack) $AI_FLAGS = @() if ($BuildAI) { $AI_FLAGS = @("--collect-all", "demucs", "--collect-all", "torch") } # 2. Grab a static ffmpeg build (BtbN build — includes libmp3lame) $ffdir = "third_party\ffmpeg\bin" if (-not (Test-Path "$ffdir\ffmpeg.exe")) { New-Item -ItemType Directory -Force -Path $ffdir | Out-Null $zip = "third_party\ffmpeg.zip" $url = "https://github.com/BtbN/FFmpeg-Builds/releases/latest/download/ffmpeg-master-latest-win64-gpl.zip" Write-Host "Downloading ffmpeg (one-time)..." Invoke-WebRequest -Uri $url -OutFile $zip Expand-Archive $zip -DestinationPath "third_party\ffmpeg_tmp" $found = Get-ChildItem -Recurse "third_party\ffmpeg_tmp" -Filter "ffmpeg.exe" | Select-Object -First 1 Copy-Item $found.FullName "$ffdir\" $probe = Join-Path $found.DirectoryName "ffprobe.exe" if (Test-Path $probe) { Copy-Item $probe "$ffdir\" } Remove-Item $zip -Force; Remove-Item "third_party\ffmpeg_tmp" -Recurse -Force } # 3. PyInstaller & ".venv\Scripts\pyinstaller.exe" --noconfirm --onefile --windowed --name VoiceGrab ` --add-binary "$ffdir\ffmpeg.exe;." ` --add-binary "$ffdir\ffprobe.exe;." ` --add-data "assets\icon.png;assets" ` --icon "assets\icon.ico" ` @AI_FLAGS ` voicegrab.py Write-Host "Built dist\VoiceGrab.exe" Write-Host "" Write-Host "Next: build the installer with Inno Setup:" Write-Host ' "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" installer\VoiceGrab.iss'