$ErrorActionPreference = 'Stop'

$root = 'C:\Users\seven\Qwen3-TTS'
$logs = Join-Path $root 'logs'
New-Item -ItemType Directory -Force -Path $logs | Out-Null
Start-Transcript -Path (Join-Path $logs 'audiobook-receiver.log') -Append | Out-Null
$env:QWEN_TTS_ROOT = $root
$env:HF_HUB_OFFLINE = '1'
$env:TRANSFORMERS_OFFLINE = '1'
Set-Location (Join-Path $root 'service')

try {
    & (Join-Path $root '.venv\Scripts\python.exe') -m uvicorn audiobook_service:app `
        --host 0.0.0.0 `
        --port 8765 `
        --workers 1
} finally {
    Stop-Transcript | Out-Null
}

