Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: voice mode Windows compatibility (setup script, piper TTS, binary detection)
[._.]/ Adam Eivyf517631a5ab2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 8b053ec07d..a1b4b6a452 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -11,3 +11,7 @@## Changed- **Send to Video carries the source image's prompts.** Clicking "Send to Video" on an Image Gen result, gallery card, or lightbox — or the same action from Media History — now pre-populates the Video Gen prompt and negative prompt from the source image's metadata. Previously only the source image filename was passed, leaving the user to retype or paste the prompt to keep the same scene direction. The flow piggybacks on the existing `?sourceImageFile=` query-param hand-off: `?prompt=` and `?negativePrompt=` are added when the source has them, and `VideoGen.jsx` reads both on first render and re-syncs on subsequent navigations (mirroring the existing source-image effect). Files: `client/src/pages/ImageGen.jsx`, `client/src/pages/MediaHistory.jsx`, `client/src/pages/VideoGen.jsx`.++## Fixed++- **Voice mode works on Windows.** The voice setup script and TTS engine now run correctly on Windows: `bootstrap.js` invokes `pwsh` with a PowerShell setup script (`scripts/setup-voice.ps1`) instead of the macOS-only bash/Homebrew script; `which` uses `where` on Windows; `verifyBinaries` checks the local piper install path first (skipping a wasteful PATH subprocess when the binary is present); `tts-piper.js` writes piper output to a temp file on Windows to avoid CR+LF corruption of binary WAV data from text-mode stdout. Shared platform constants (`IS_WIN`, `PIPER_BIN_NAME`) extracted to `config.js`.diff --git a/scripts/setup-voice.ps1 b/scripts/setup-voice.ps1new file mode 100644index 0000000000..080936dbbc--- /dev/null+++ b/scripts/setup-voice.ps1@@ -0,0 +1,120 @@+# Bootstrap local voice stack on Windows: whisper.cpp (STT) + active TTS backend.+# Safe to re-run: installs only what's missing, downloads only what's missing.+#+# Env overrides (same as setup-voice.sh):+# STT_ENGINE 'whisper' (default) | 'web-speech'+# MODEL_NAME Whisper GGUF to fetch (default: ggml-base.en.bin)+# VOICE_NAME Piper voice name (default: en_GB-jenny_dioco-medium)+# TTS_ENGINE 'kokoro' (default) | 'piper'+# INSTALL_COREML '1' — ignored on Windows (CoreML is Apple Silicon only)++$ErrorActionPreference = 'Stop'++$VOICE_HOME = Join-Path $env:USERPROFILE '.portos\voice'+$MODELS_DIR = Join-Path $VOICE_HOME 'models'+$VOICES_DIR = Join-Path $VOICE_HOME 'voices'+$PIPER_DIR = Join-Path $VOICE_HOME 'piper'++$MODEL_NAME = if ($env:MODEL_NAME) { $env:MODEL_NAME } else { 'ggml-base.en.bin' }+$VOICE_NAME = if ($env:VOICE_NAME) { $env:VOICE_NAME } else { 'en_GB-jenny_dioco-medium' }+$TTS_ENGINE = if ($env:TTS_ENGINE) { $env:TTS_ENGINE } else { 'kokoro' }+$STT_ENGINE = if ($env:STT_ENGINE) { $env:STT_ENGINE } else { 'whisper' }++New-Item -ItemType Directory -Force -Path $MODELS_DIR | Out-Null+New-Item -ItemType Directory -Force -Path $VOICES_DIR | Out-Null++function Have-Command($cmd) {+ [bool](Get-Command $cmd -ErrorAction SilentlyContinue)+}++function Download-File($url, $dest) {+ Write-Host "⬇️ $(Split-Path $dest -Leaf)"+ Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing+}++# ── whisper-server ────────────────────────────────────────────────────────────+if ($STT_ENGINE -eq 'whisper') {+ $whisperExe = Join-Path $PIPER_DIR '..\whisper\whisper-server.exe'+ $whisperOnPath = Have-Command 'whisper-server'+ if (-not $whisperOnPath) {+ if (Have-Command 'winget') {+ Write-Host '📦 winget install ggerganov.whisper.cpp'+ winget install --id ggerganov.whisper.cpp --accept-source-agreements --accept-package-agreements+ } elseif (Have-Command 'scoop') {+ Write-Host '📦 scoop install whisper'+ scoop install whisper+ } else {+ Write-Host '❌ whisper-server not found and no package manager available.' -ForegroundColor Red+ Write-Host ' Install via: winget install ggerganov.whisper.cpp' -ForegroundColor Yellow+ Write-Host ' Or: scoop install whisper' -ForegroundColor Yellow+ Write-Host ' Or download: https://github.com/ggerganov/whisper.cpp/releases' -ForegroundColor Yellow+ exit 1+ }+ }+} else {+ Write-Host "ℹ️ STT_ENGINE=$STT_ENGINE — skipping whisper-cpp install and model download"+}++# ── piper TTS binary ──────────────────────────────────────────────────────────+if ($TTS_ENGINE -eq 'piper') {+ $piperExe = Join-Path $PIPER_DIR 'piper.exe'+ if (-not (Test-Path $piperExe)) {+ $PIPER_VERSION = '2023.11.14-2'+ $arch = if ([System.Environment]::Is64BitOperatingSystem) { 'amd64' } else { 'x86' }+ $zipName = "piper_windows_${arch}.zip"+ $url = "https://github.com/rhasspy/piper/releases/download/${PIPER_VERSION}/${zipName}"+ $tmp = Join-Path $env:TEMP $zipName+ Write-Host "⬇️ Piper TTS → $PIPER_DIR"+ Invoke-WebRequest -Uri $url -OutFile $tmp -UseBasicParsing+ New-Item -ItemType Directory -Force -Path $PIPER_DIR | Out-Null+ Expand-Archive -Path $tmp -DestinationPath $VOICE_HOME -Force+ Remove-Item $tmp -ErrorAction SilentlyContinue+ }+}++# ── Whisper GGUF model ────────────────────────────────────────────────────────+if ($STT_ENGINE -eq 'whisper') {+ $modelPath = Join-Path $MODELS_DIR $MODEL_NAME+ if (-not (Test-Path $modelPath)) {+ $url = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/$MODEL_NAME"+ Write-Host "⬇️ Whisper model → $modelPath"+ Invoke-WebRequest -Uri $url -OutFile $modelPath -UseBasicParsing+ }+}++# ── Piper voice (ONNX + JSON sidecar) ────────────────────────────────────────+if ($TTS_ENGINE -eq 'piper') {+ $onnxPath = Join-Path $VOICES_DIR "$VOICE_NAME.onnx"+ $jsonPath = Join-Path $VOICES_DIR "$VOICE_NAME.onnx.json"+ if (-not (Test-Path $onnxPath)) {+ # en_US-ryan-high → en / en_US / ryan / high+ $locale = ($VOICE_NAME -split '-')[0] # en_US+ $lang = ($locale -split '_')[0] # en+ $rest = $VOICE_NAME.Substring($locale.Length + 1) # ryan-high+ $parts = $rest -split '-'+ $speaker = $parts[0] # ryan+ $quality = $parts[1] # high+ $base = "https://huggingface.co/rhasspy/piper-voices/resolve/main/$lang/$locale/$speaker/$quality"+ Write-Host "⬇️ Piper voice → $onnxPath"+ Invoke-WebRequest -Uri "$base/$VOICE_NAME.onnx" -OutFile $onnxPath -UseBasicParsing+ Invoke-WebRequest -Uri "$base/$VOICE_NAME.onnx.json" -OutFile $jsonPath -UseBasicParsing+ }+}++# ── Summary ───────────────────────────────────────────────────────────────────+Write-Host '✅ Voice stack ready'+if ($STT_ENGINE -eq 'whisper') {+ $wCmd = Get-Command 'whisper-server' -ErrorAction SilentlyContinue+ $w = if ($wCmd) { $wCmd.Source } else { '<not installed>' }+ Write-Host " whisper-server: $w"+ Write-Host " stt model: $(Join-Path $MODELS_DIR $MODEL_NAME)"+} else {+ Write-Host " stt engine: $STT_ENGINE (browser-native, no server provisioning)"+}+Write-Host " tts engine: $TTS_ENGINE"+if ($TTS_ENGINE -eq 'piper') {+ Write-Host " piper: $(Join-Path $PIPER_DIR 'piper.exe')"+ Write-Host " piper voice: $(Join-Path $VOICES_DIR "$VOICE_NAME.onnx")"+} else {+ Write-Host ' kokoro models: managed by transformers.js (~/.cache/huggingface/)'+}diff --git a/server/services/voice/bootstrap.js b/server/services/voice/bootstrap.jsindex 08841ce3a9..13ba13be5b 100644--- a/server/services/voice/bootstrap.js+++ b/server/services/voice/bootstrap.js@@ -8,7 +8,7 @@ import { basename, join } from 'path';import { createServer } from 'net';import { PATHS } from '../../lib/fileUtils.js';import { execPm2, getAppStatus } from '../pm2.js';-import { expandPath, piperVoiceTildePath } from './config.js';+import { expandPath, piperVoiceTildePath, voiceHome, IS_WIN, PIPER_BIN_NAME } from './config.js';import { isToolCapable, isReasoningModel } from './llm.js';export const pexec = promisify(execFile);@@ -16,15 +16,20 @@ export const pexec = promisify(execFile);export const WHISPER_APP = 'portos-whisper';export const which = async (bin) => {- const res = await pexec('which', [bin]).catch(() => null);- return res?.stdout.trim() || null;+ const res = await pexec(IS_WIN ? 'where' : 'which', [bin]).catch(() => null);+ return res?.stdout.split(/\r?\n/)[0].trim() || null;};export const verifyBinaries = async (cfg) => {- const [whisper, piper] = await Promise.all([which('whisper-server'), which('piper')]);- // Only require piper when active engine actually uses it.+ const piperLocal = join(voiceHome(), 'piper', PIPER_BIN_NAME);+ const piperResolved = existsSync(piperLocal) ? piperLocal : null;+ // Only search PATH when piper isn't locally installed — spawning `where`/`which` is expensive.+ const [whisper, piperOnPath] = await Promise.all([+ which('whisper-server'),+ piperResolved ? Promise.resolve(null) : which('piper'),+ ]);const piperRequired = cfg?.tts?.engine === 'piper';- return { whisper, piper, piperRequired };+ return { whisper, piper: piperResolved ?? piperOnPath, piperRequired };};export const verifyModels = (cfg) => {@@ -49,7 +54,6 @@ export const verifyModels = (cfg) => {const parseVoiceName = (voicePath) => basename(voicePath).replace(/\.onnx$/, '');export const runSetupScript = async (cfg) => {- const scriptPath = join(PATHS.root, 'scripts', 'setup-voice.sh');const modelName = basename(expandPath(cfg.stt.modelPath));const voiceName = cfg.tts.engine === 'piper' ? parseVoiceName(expandPath(cfg.tts.piper.voicePath)) : '';const sttEngine = cfg.stt?.engine || 'whisper';@@ -57,17 +61,18 @@ export const runSetupScript = async (cfg) => {...process.env,MODEL_NAME: modelName,VOICE_NAME: voiceName,- // Pass STT_ENGINE so the script can skip whisper install + model download- // when the user picked Web Speech (browser-native) — they'd otherwise pay- // the Homebrew + GGUF model cost for a feature they don't use.STT_ENGINE: sttEngine,TTS_ENGINE: cfg.tts.engine || 'kokoro',INSTALL_COREML: cfg.stt.coreml ? '1' : '0',};- console.log(`🔧 voice: setup-voice.sh (stt=${sttEngine}/${modelName}, tts=${cfg.tts.engine}, coreml=${env.INSTALL_COREML})`);+ console.log(`🔧 voice: setup-voice (stt=${sttEngine}/${modelName}, tts=${cfg.tts.engine}, coreml=${env.INSTALL_COREML})`);// 10-minute cap — large models + slow network can legitimately take several// minutes, but a hung curl must not pin the HTTP request that triggered us.- const { stdout, stderr } = await pexec('bash', [scriptPath], {+ const [cmd, args] = IS_WIN+ ? ['pwsh', ['-ExecutionPolicy', 'Bypass', '-File', 'scripts\\setup-voice.ps1']]+ : ['bash', ['scripts/setup-voice.sh']];+ const { stdout, stderr } = await pexec(cmd, args, {+ cwd: PATHS.root,env,maxBuffer: 64 * 1024 * 1024,timeout: 10 * 60 * 1000,diff --git a/server/services/voice/config.js b/server/services/voice/config.jsindex befc0084de..c1f6393565 100644--- a/server/services/voice/config.js+++ b/server/services/voice/config.js@@ -122,3 +122,6 @@ export const updateVoiceConfig = async (patch) => {export const voiceHome = () => VOICE_HOME;export const piperVoiceTildePath = (id) => `~/.portos/voice/voices/${id}.onnx`;++export const IS_WIN = process.platform === 'win32';+export const PIPER_BIN_NAME = IS_WIN ? 'piper.exe' : 'piper';diff --git a/server/services/voice/tts-piper.js b/server/services/voice/tts-piper.jsindex a060389d4d..3b20142467 100644--- a/server/services/voice/tts-piper.js+++ b/server/services/voice/tts-piper.js@@ -1,14 +1,15 @@// Piper TTS backend — spawn-per-request CLI: text on stdin, WAV on stdout.import { spawn } from 'child_process';-import { existsSync } from 'fs';+import { existsSync, readFileSync, unlinkSync } from 'fs';+import { tmpdir } from 'os';import { delimiter, join } from 'path';-import { expandPath, piperVoiceTildePath, voiceHome } from './config.js';+import { expandPath, piperVoiceTildePath, voiceHome, IS_WIN, PIPER_BIN_NAME } from './config.js';import { PIPER_VOICES, findPiperVoice } from './piper-voices.js';const PIPER_TIMEOUT_MS = 30_000;const VOICES_DIR = join(voiceHome(), 'voices');-const PIPER_BIN = join(voiceHome(), 'piper', 'piper');+const PIPER_BIN = join(voiceHome(), 'piper', PIPER_BIN_NAME);const voicePathFor = (id) => join(VOICES_DIR, `${id}.onnx`);@@ -21,7 +22,10 @@ export const synthesizePiper = (text, cfg, signal) => {const rate = Math.max(0.25, Math.min(4, cfg.rate ?? 1.0));const lengthScale = String(1 / rate);- const args = ['--model', voicePath, '--length_scale', lengthScale, '--output_file', '-'];+ // On Windows, piper.exe writes stdout in text mode which corrupts binary WAV+ // (CR+LF expansion). Use a temp file and read it back instead.+ const tmpFile = IS_WIN ? join(tmpdir(), `piper-${Date.now()}.wav`) : null;+ const args = ['--model', voicePath, '--length_scale', lengthScale, '--output_file', tmpFile ?? '-'];// Multi-speaker voices (VCTK) need a speaker index. Prefer the per-session// override from config, fall back to the catalog default.@@ -60,7 +64,12 @@ export const synthesizePiper = (text, cfg, signal) => {fn(arg);};const doResolve = settle(resolve);- const doReject = settle(reject);+ const _reject = settle(reject);+ // Clean up temp file on every rejection path (timeout, abort, error, non-zero exit).+ const doReject = (err) => {+ if (tmpFile) try { unlinkSync(tmpFile); } catch { /* best effort */ }+ _reject(err);+ };const killTimer = setTimeout(() => {killed = true;@@ -87,7 +96,13 @@ export const synthesizePiper = (text, cfg, signal) => {child.on('close', (code) => {if (killed) return doReject(new Error('piper synthesis aborted'));if (code !== 0) return doReject(new Error(`piper exited ${code}: ${errBuf.slice(0, 400)}`));- doResolve({ wav: Buffer.concat(chunks), latencyMs: Date.now() - started });+ if (tmpFile) {+ try { doResolve({ wav: readFileSync(tmpFile), latencyMs: Date.now() - started }); }+ catch (err) { doReject(err); }+ finally { try { unlinkSync(tmpFile); } catch { /* already gone */ } }+ } else {+ doResolve({ wav: Buffer.concat(chunks), latencyMs: Date.now() - started });+ }});child.stdin.end(text);