# Build the self-contained Audio Engine installer on Windows. # # Run this on a Windows machine. The Linux->Windows cross-compile is not viable # for the full audio.cpp framework (sentencepiece's CMake uses try_run(), which # cannot execute a Windows test binary on a Linux host), so the engine is built # natively here with MSVC. ~15 min on a cold machine. # # $env:AUDIO_CPP_SRC = "C:\path\to\audio.cpp" # a checkout of 0xShug0/audio.cpp # powershell -ExecutionPolicy Bypass -File scripts\build-windows.ps1 # # Output: src-tauri\target\release\bundle\nsis\Audio Engine__x64-setup.exe $ErrorActionPreference = "Stop" Set-Location (Split-Path $PSScriptRoot -Parent) function Have($n) { $null -ne (Get-Command $n -ErrorAction SilentlyContinue) } $SRC = $env:AUDIO_CPP_SRC if (-not $SRC) { throw "Set AUDIO_CPP_SRC to an audio.cpp checkout (github.com/0xShug0/audio.cpp)" } if (-not (Test-Path $SRC)) { throw "AUDIO_CPP_SRC does not exist: $SRC" } Write-Host "== prerequisites ==" -ForegroundColor Cyan if (-not (Have cargo)) { winget install --id Rustlang.Rustup -e --accept-source-agreements --accept-package-agreements; $env:PATH = "$env:USERPROFILE\.cargo\bin;$env:PATH" } if (-not (Have node)) { winget install --id OpenJS.NodeJS.LTS -e --accept-source-agreements --accept-package-agreements; $env:PATH = "$env:ProgramFiles\nodejs;$env:PATH" } if (-not (Have pnpm)) { npm install -g pnpm } if (-not (Have cmake)) { winget install --id Kitware.CMake -e --accept-source-agreements --accept-package-agreements } if (-not (Have ninja)) { winget install --id Ninja-build.Ninja -e --accept-source-agreements --accept-package-agreements } # The MSVC C++ build tools are what people forget; audio.cpp is a C++ build. $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" if (-not (Test-Path $vswhere)) { Write-Host "installing Visual Studio Build Tools (C++ workload)..." winget install --id Microsoft.VisualStudio.2022.BuildTools -e ` --override "--quiet --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended" } Write-Host "== building the audio.cpp engine (CPU, sense_asr + pocket_tts) ==" -ForegroundColor Cyan $eng = Join-Path $SRC "build\win-cpu" cmake -S $SRC -B $eng -G Ninja -DCMAKE_BUILD_TYPE=Release ` -DAUDIOCPP_MODEL_SET=custom -DAUDIOCPP_MODELS=sense_asr,pocket_tts ` -DENGINE_ENABLE_OPENMP=OFF -DGGML_METAL=OFF cmake --build $eng --target audiocpp_server -j 8 $exe = Join-Path $eng "bin\audiocpp_server.exe" if (-not (Test-Path $exe)) { $exe = Get-ChildItem -Recurse -Filter audiocpp_server.exe -Path $eng | Select-Object -First 1 -ExpandProperty FullName } if (-not $exe) { throw "engine build finished but audiocpp_server.exe was not found under $eng" } Write-Host "== vendoring engine as sidecar + resources ==" -ForegroundColor Cyan New-Item -ItemType Directory -Force -Path "src-tauri\binaries" | Out-Null # Tauri sidecar naming: -.exe Copy-Item $exe "src-tauri\binaries\audiocpp_server-x86_64-pc-windows-msvc.exe" -Force Remove-Item -Recurse -Force "src-tauri\resources\assets","src-tauri\resources\model_specs" -ErrorAction SilentlyContinue New-Item -ItemType Directory -Force -Path "src-tauri\resources\assets" | Out-Null Copy-Item -Recurse "$SRC\assets\framework" "src-tauri\resources\assets\framework" -Force Copy-Item -Recurse "$SRC\model_specs" "src-tauri\resources\model_specs" -Force Write-Host "== building the app ==" -ForegroundColor Cyan pnpm install pnpm tauri build --bundles nsis $setup = Get-ChildItem -Recurse -Filter "*-setup.exe" -Path "src-tauri\target\release\bundle" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -First 1 if ($setup) { Write-Host "" Write-Host "installer: $($setup.FullName)" -ForegroundColor Green Write-Host "Per-user install; unsigned, so SmartScreen warns on first run (More info -> Run anyway)." } else { throw "the build finished but no installer was produced — check the output above" }