From 3803f0987d7fd38cbd754f3dc37caa29247c852c Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Wed, 01 Jul 2026 23:21:27 +0800
Subject: [PATCH] Merge Windows preview build
---
privatevoice.src/scripts/build-windows-preview.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/privatevoice.src/scripts/build-windows-preview.sh b/privatevoice.src/scripts/build-windows-preview.sh
new file mode 100755
index 0000000..680afe1
--- /dev/null
+++ b/privatevoice.src/scripts/build-windows-preview.sh
@@ -0,0 +1,91 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+cd "$ROOT_DIR"
+
+APP_VERSION="2.1.38"
+APP_BUILD="20260629.2014"
+ARCH="${1:-amd64}"
+
+if [[ "$ARCH" != "amd64" ]]; then
+ echo "Only amd64 is supported for the Windows preview build." >&2
+ exit 2
+fi
+
+for tool in go npm x86_64-w64-mingw32-gcc x86_64-w64-mingw32-g++; do
+ if ! command -v "$tool" >/dev/null 2>&1; then
+ echo "Missing required tool: $tool" >&2
+ exit 127
+ fi
+done
+
+OUT_ROOT="$ROOT_DIR/build/windows-preview"
+OUT_DIR="$OUT_ROOT/PrivateVoice-Dictation-${APP_VERSION}-build${APP_BUILD}-windows-${ARCH}-preview"
+ZIP_PATH="$OUT_ROOT/PrivateVoice-Dictation-${APP_VERSION}-build${APP_BUILD}-windows-${ARCH}-preview.zip"
+
+rm -rf "$OUT_DIR" "$ZIP_PATH"
+mkdir -p "$OUT_DIR"
+
+echo "Building frontend..."
+npm --prefix frontend install
+npm --prefix frontend run build
+
+SHERPA_WINDOWS_DIR="$(go list -m -f '{{.Dir}}' github.com/k2-fsa/sherpa-onnx-go-windows)"
+SHERPA_DLL_DIR="$SHERPA_WINDOWS_DIR/lib/x86_64-pc-windows-gnu"
+for dll in onnxruntime.dll sherpa-onnx-c-api.dll sherpa-onnx-cxx-api.dll; do
+ if [[ ! -f "$SHERPA_DLL_DIR/$dll" ]]; then
+ echo "Missing sherpa runtime DLL: $SHERPA_DLL_DIR/$dll" >&2
+ exit 3
+ fi
+done
+
+echo "Building Windows executable..."
+GOOS=windows \
+GOARCH=amd64 \
+CGO_ENABLED=1 \
+CC=x86_64-w64-mingw32-gcc \
+CXX=x86_64-w64-mingw32-g++ \
+go build \
+ -buildvcs=false \
+ -ldflags="-H windowsgui" \
+ -o "$OUT_DIR/PrivateVoice Dictation.exe" \
+ .
+
+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/"
+cp "$ROOT_DIR/scripts/RUN-WINDOWS-QA.cmd" "$OUT_DIR/"
+
+cat >"$OUT_DIR/README-WINDOWS-PREVIEW.txt" <<EOF
+PrivateVoice Dictation Windows Preview
+Version: ${APP_VERSION}
+Build: ${APP_BUILD}
+Architecture: Windows x64
+
+Scope:
+- Technical preview based on PrivateVoice Dictation ${APP_VERSION}.
+- The first Windows preview supports SenseVoice Chinese recognition only.
+- Other models are visible but disabled in this preview build.
+
+How to run:
+1. Extract the whole folder.
+2. Keep the EXE and DLL files in the same directory.
+3. Double-click "RUN-WINDOWS-QA.cmd".
+4. If Windows blocks the command file, right-click "QA-WINDOWS-PREVIEW.ps1" and choose "Run with PowerShell", or run this command from the extracted folder:
+ powershell -ExecutionPolicy Bypass -File .\\QA-WINDOWS-PREVIEW.ps1
+5. Follow the on-screen checklist. It will collect WebView2/audio preflight data, launch the app, open a Notepad target file, ask you to dictate once, and collect logs plus the saved target text.
+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 and the saved Notepad target text. Review before sharing if needed.
+EOF
+
+(cd "$OUT_ROOT" && zip -qr "$(basename "$ZIP_PATH")" "$(basename "$OUT_DIR")")
+
+echo "Built: $OUT_DIR"
+echo "Zip: $ZIP_PATH"
--
Gitblit v1.9.3