# Windows 构建指南 ## 构建说明 **重要提示**: 由于网络和系统限制,强烈建议在 **Windows 系统上直接构建** Windows 版本。 在 Linux 系统上构建 Windows 版本需要 Wine 且网络状况要求较高,可能无法成功。 --- ## 方法一:在 Windows 上构建(推荐) ### 1. 环境准备 ```powershell # 安装 Node.js 20+ # 从 https://nodejs.org 下载安装 # 克隆项目 git clone https://gitea.impressionyang.top/impressionyang/impress_asr_input.git cd impress-asr-input # 安装依赖 npm install ``` ### 2. 放入模型文件 将 ONNX 模型放入 `models/` 目录: - `sensevoice.onnx` - `whisper.onnx` - `paraformer.onnx` ### 3. 构建 ```powershell # 构建 ZIP 包(无需签名) npm run build:win:zip # 构建 NSIS 安装程序 npm run build:win # 构建解压目录版本(用于测试) npm run build:win:dir ``` 输出目录:`release/` --- ## 方法二:使用预编译的 Electron 手动打包 如果在 Linux 上需要快速打包,可以使用以下手动方式: ### 步骤 1: 编译 TypeScript ```bash npm run build ``` ### 步骤 2: 下载 Electron 从国内镜像下载 Electron: ```bash # 访问 https://npmmirror.com/mirrors/electron/ # 下载 electron-v28.3.3-win32-x64.zip ``` ### 步骤 3: 打包 ```bash # 创建发布目录 mkdir -p release/impress-asr-input-win-x64 # 解压 Electron 到发布目录 unzip electron-v28.3.3-win32-x64.zip -d release/impress-asr-input-win-x64/ # 复制应用文件 cp -r dist/* release/impress-asr-input-win-x64/resources/app/ # 压缩 cd release/ zip -r impress-asr-input-win-x64.zip impress-asr-input-win-x64/ ``` --- ## 构建输出 ``` release/ ├── win-unpacked/ # 未打包版本(用于测试) │ ├── Impress ASR Input.exe │ ├── resources/ │ └── ... ├── Impress ASR Input-0.1.0-win-x64.zip # ZIP 压缩包 └── Impress ASR Input-0.1.0-win-x64-setup.exe # NSIS 安装程序 ``` --- ## 常见问题 ### 1. Electron 下载失败 ```bash # 使用国内镜像 export ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/" export npm_config_electron_mirror="https://npmmirror.com/mirrors/electron/" ``` ### 2. winCodeSign 下载失败 / 签名错误 electron-builder 默认会尝试下载代码签名工具,在 Linux 上可能失败。 解决方案: 1. 在 Windows 上构建(推荐) 2. 或手动打包(见方法二) ### 3. 缺少 wine64 ```bash # Ubuntu/Debian 安装 Wine sudo apt-get install wine64 ``` 但 Wine 配置复杂,仍建议在 Windows 上构建。 ### 4. 图标文件缺失 构建时会使用默认图标,如需自定义: 1. 准备 `icon.ico` (256x256) 2. 放入 `build/` 目录 3. 在 `package.json` 的 `build.win` 中添加 `"icon": "build/icon.ico"` --- ## 运行应用 解压后运行: ``` Impress ASR Input.exe ``` 或命令行模式: ``` node dist/main.js start ``` --- ## 快速验证(无模型) 应用支持无模型启动,用于配置和测试: ```bash npm start -- start ``` 会显示模型下载指引和配置说明。