From 58c6b963b81e07765d29cda9410399e9644c886f Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Tue, 30 Jun 2026 03:23:24 +0800
Subject: [PATCH] Add Windows preview QA collector
---
privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1 | 124 +++++++++++++++++++++++++++++++++++++++++
privatevoice.src/scripts/build-windows-preview.sh | 10 ++-
CHANGELOG.md | 1
CODEGRAPH.md | 2
4 files changed, 134 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3ebcf88..fc88668 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@
### Windows 技术预览
- **新增 Windows 预览构建脚本**:`privatevoice.src/scripts/build-windows-preview.sh` 可生成 Windows x64 预览目录和 zip。
+- **内置 Windows 真机 QA 采集脚本**:预览包包含 `QA-WINDOWS-PREVIEW.ps1`,用于启动 App、提示完成一次听写,并收集日志证据。
- **预览版只开放 SenseVoice**:Windows build 中其他模型仍可见但置灰禁用,避免用户选择尚未验证的模型导致启动或识别失败。
- **打包 sherpa/onnxruntime 运行时 DLL**:预览包包含 `onnxruntime.dll`、`sherpa-onnx-c-api.dll`、`sherpa-onnx-cxx-api.dll`。
- **交付边界**:该产物是 Windows 技术预览,不是已签名安装器,也未完成 Windows 10/11 真机 QA。
diff --git a/CODEGRAPH.md b/CODEGRAPH.md
index 3e58681..f30d7da 100644
--- a/CODEGRAPH.md
+++ b/CODEGRAPH.md
@@ -41,6 +41,7 @@
- `onnxruntime.dll`
- `sherpa-onnx-c-api.dll`
- `sherpa-onnx-cxx-api.dll`
+ - `QA-WINDOWS-PREVIEW.ps1`
- `README-WINDOWS-PREVIEW.txt`
## Standard Verification Commands
@@ -57,5 +58,6 @@
## Known Gaps
- Windows runtime QA must still be performed on Windows 10/11 hardware.
+- Run `QA-WINDOWS-PREVIEW.ps1` from the extracted preview package to collect startup, engine, recording, recognition, and paste evidence.
- The Windows preview zip is unsigned and not an installer.
- SmartScreen / Defender prompts are expected for local testing.
diff --git a/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1 b/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1
new file mode 100644
index 0000000..cf43713
--- /dev/null
+++ b/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1
@@ -0,0 +1,124 @@
+param(
+ [switch]$CollectOnly,
+ [switch]$NoLaunch,
+ [int]$WaitSeconds = 45
+)
+
+$ErrorActionPreference = "Stop"
+
+function Write-Step {
+ param([string]$Message)
+ Write-Host ""
+ Write-Host "== $Message ==" -ForegroundColor Cyan
+}
+
+function Add-Result {
+ param(
+ [System.Collections.Generic.List[string]]$Results,
+ [string]$Name,
+ [bool]$Passed,
+ [string]$Detail = ""
+ )
+ $state = if ($Passed) { "PASS" } else { "NEEDS_EVIDENCE" }
+ $line = if ($Detail) { "$state`t$Name`t$Detail" } else { "$state`t$Name" }
+ $Results.Add($line) | Out-Null
+ $color = if ($Passed) { "Green" } else { "Yellow" }
+ Write-Host "[$state] $Name $Detail" -ForegroundColor $color
+}
+
+$PackageDir = Split-Path -Parent $MyInvocation.MyCommand.Path
+$ExePath = Join-Path $PackageDir "PrivateVoice Dictation.exe"
+$RequiredFiles = @(
+ "PrivateVoice Dictation.exe",
+ "onnxruntime.dll",
+ "sherpa-onnx-c-api.dll",
+ "sherpa-onnx-cxx-api.dll"
+)
+$AppDataDir = Join-Path $env:APPDATA "PrivateVoice Input"
+$LogPath = Join-Path $AppDataDir "app.log"
+$Timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
+$EvidenceDir = Join-Path $PackageDir "qa-evidence-$Timestamp"
+$Results = [System.Collections.Generic.List[string]]::new()
+
+New-Item -ItemType Directory -Path $EvidenceDir -Force | Out-Null
+
+Write-Step "PrivateVoice Windows preview QA"
+"GeneratedAt: $(Get-Date -Format o)" | Set-Content -Encoding UTF8 (Join-Path $EvidenceDir "qa-summary.txt")
+"PackageDir: $PackageDir" | Add-Content -Encoding UTF8 (Join-Path $EvidenceDir "qa-summary.txt")
+"AppDataDir: $AppDataDir" | Add-Content -Encoding UTF8 (Join-Path $EvidenceDir "qa-summary.txt")
+
+Write-Step "Checking package files"
+foreach ($file in $RequiredFiles) {
+ $path = Join-Path $PackageDir $file
+ Add-Result $Results "file exists: $file" (Test-Path $path) $path
+}
+
+Write-Step "Collecting system information"
+try {
+ Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer, CsSystemType, CsProcessors, CsTotalPhysicalMemory |
+ Format-List | Out-String | Set-Content -Encoding UTF8 (Join-Path $EvidenceDir "system-info.txt")
+ Add-Result $Results "system info collected" $true
+} catch {
+ Add-Result $Results "system info collected" $false $_.Exception.Message
+}
+
+if (-not $CollectOnly -and -not $NoLaunch) {
+ Write-Step "Launching app"
+ if (-not (Test-Path $ExePath)) {
+ throw "Missing executable: $ExePath"
+ }
+ Start-Process -FilePath $ExePath -WorkingDirectory $PackageDir | Out-Null
+}
+
+Write-Step "Waiting for app log"
+$deadline = (Get-Date).AddSeconds($WaitSeconds)
+while ((Get-Date) -lt $deadline -and -not (Test-Path $LogPath)) {
+ Start-Sleep -Milliseconds 500
+}
+Add-Result $Results "app log exists" (Test-Path $LogPath) $LogPath
+
+Write-Step "Checking process"
+$processes = Get-Process | Where-Object { $_.ProcessName -like "PrivateVoice*" -or $_.Path -eq $ExePath } | Select-Object Id, ProcessName, Path
+$processes | Format-Table -AutoSize | Out-String | Set-Content -Encoding UTF8 (Join-Path $EvidenceDir "processes.txt")
+Add-Result $Results "PrivateVoice process visible" (($processes | Measure-Object).Count -gt 0)
+
+if (-not $CollectOnly) {
+ Write-Step "Manual runtime check"
+ Write-Host "1. Keep this PowerShell window open." -ForegroundColor White
+ Write-Host "2. In PrivateVoice, make sure the SenseVoice model is installed and the engine is ready." -ForegroundColor White
+ Write-Host "3. Open Notepad or a browser text field." -ForegroundColor White
+ Write-Host "4. Use the configured hotkey and speak: 这是 Windows 预览版测试。" -ForegroundColor White
+ Write-Host "5. Confirm whether the text appears in the target input field." -ForegroundColor White
+ Read-Host "Press Enter after you complete one dictation attempt"
+}
+
+Write-Step "Collecting logs"
+if (Test-Path $LogPath) {
+ Copy-Item $LogPath (Join-Path $EvidenceDir "app.log") -Force
+ $logText = Get-Content $LogPath -Raw -ErrorAction SilentlyContinue
+ Add-Result $Results "startup log found" ($logText -match "PrivateVoice Dictation starting")
+ Add-Result $Results "engine ready log found" ($logText -match "ASR engine ready|Engine initialized")
+ Add-Result $Results "recording log found" ($logText -match "Recording started")
+ Add-Result $Results "recognized text log found" ($logText -match "Recognized:")
+ Add-Result $Results "paste success log found" ($logText -match "PERF paste_done.*result=success|PERF fallback_type_done.*result=success")
+}
+
+$ConfigPath = Join-Path $AppDataDir "config.json"
+if (Test-Path $ConfigPath) {
+ Copy-Item $ConfigPath (Join-Path $EvidenceDir "config.json") -Force
+}
+
+$Results | Set-Content -Encoding UTF8 (Join-Path $EvidenceDir "qa-results.tsv")
+$Results | Add-Content -Encoding UTF8 (Join-Path $EvidenceDir "qa-summary.txt")
+
+Write-Step "Evidence package"
+$ZipPath = "$EvidenceDir.zip"
+if (Test-Path $ZipPath) {
+ Remove-Item $ZipPath -Force
+}
+Compress-Archive -Path (Join-Path $EvidenceDir "*") -DestinationPath $ZipPath
+Write-Host "Evidence directory: $EvidenceDir" -ForegroundColor Green
+Write-Host "Evidence zip: $ZipPath" -ForegroundColor Green
+
+Write-Host ""
+Write-Host "Send back the evidence zip if any check is NEEDS_EVIDENCE or the app does not behave correctly." -ForegroundColor Yellow
diff --git a/privatevoice.src/scripts/build-windows-preview.sh b/privatevoice.src/scripts/build-windows-preview.sh
index b12d503..467fad8 100755
--- a/privatevoice.src/scripts/build-windows-preview.sh
+++ b/privatevoice.src/scripts/build-windows-preview.sh
@@ -55,6 +55,7 @@
cp "$SHERPA_DLL_DIR/onnxruntime.dll" "$OUT_DIR/"
cp "$SHERPA_DLL_DIR/sherpa-onnx-c-api.dll" "$OUT_DIR/"
cp "$SHERPA_DLL_DIR/sherpa-onnx-cxx-api.dll" "$OUT_DIR/"
+cp "$ROOT_DIR/scripts/QA-WINDOWS-PREVIEW.ps1" "$OUT_DIR/"
cat >"$OUT_DIR/README-WINDOWS-PREVIEW.txt" <<EOF
PrivateVoice Dictation Windows Preview
@@ -70,14 +71,17 @@
How to run:
1. Extract the whole folder.
2. Keep the EXE and DLL files in the same directory.
-3. Run "PrivateVoice Dictation.exe".
-4. Download/install the SenseVoice model if prompted.
-5. Use the configured hotkey and verify text input in Notepad or a browser text field.
+3. Right-click "QA-WINDOWS-PREVIEW.ps1" and choose "Run with PowerShell".
+4. If PowerShell blocks scripts, run this command from the extracted folder:
+ powershell -ExecutionPolicy Bypass -File .\\QA-WINDOWS-PREVIEW.ps1
+5. Follow the on-screen checklist. It will launch the app, ask you to dictate once, and collect logs.
+6. You can also run "PrivateVoice Dictation.exe" directly after QA.
Known limitations:
- This is not a signed Windows installer.
- Real Windows audio, hotkey, paste, tray, and WebView2 behavior still need QA on Windows 10/11.
- If Windows Defender or SmartScreen blocks it, allow it only for local testing.
+- The QA evidence zip may contain app logs with recognized text. Review before sharing if needed.
EOF
(cd "$OUT_ROOT" && zip -qr "$(basename "$ZIP_PATH")" "$(basename "$OUT_DIR")")
--
Gitblit v1.9.3