Skip to content

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

fix: address Claude review of Kokoro retirement lifecycle

[._.]/ Adam Eivy34b6ec0ce768
diff --git a/client/public/flows.json b/client/public/flows.json
index 8292eb9726..c5d61bf551 100644
--- a/client/public/flows.json
+++ b/client/public/flows.json
@@ -85,7 +85,7 @@
{ "id": "ext.cosRunner", "label": "CoS Runner (portos-cos)", "group": "external", "file": "server/cos-runner/index.js", "desc": "Standalone PM2 process that spawns and streams AI agent CLIs, isolated from the main server." },
{ "id": "ext.pythonRunners", "label": "Python media runners", "group": "external", "desc": "mflux/diffusers image, video, and LoRA-training runner processes." },
{ "id": "ext.whisper", "label": "Whisper (STT)", "group": "external", "desc": "Speech-to-text binary transcribing voice turns." },
- { "id": "ext.tts", "label": "Piper / Kokoro (TTS)", "group": "external", "desc": "Text-to-speech binaries synthesizing reply audio sentence-by-sentence." },
+ { "id": "ext.tts", "label": "Piper / Qwen3 (TTS)", "group": "external", "desc": "Text-to-speech binaries synthesizing reply audio sentence-by-sentence." },
{ "id": "ext.pty", "label": "PTY (node-pty)", "group": "external", "desc": "Pseudo-terminal processes running the user's shell." },
{ "id": "ext.peers", "label": "Federated peers", "group": "external", "desc": "Other PortOS installs reachable over the private network." },
{ "id": "ext.updateSh", "label": "update.sh", "group": "external", "file": "update.sh", "desc": "Detached updater script: git pull --rebase --autostash + PM2 restart." },
@@ -139,7 +139,7 @@
{ "from": "svc.voicePipeline", "to": "svc.voiceTools", "transport": "call", "label": "dispatchTool", "payload": "tool calls { name, args } from the LLM loop" },
{ "from": "svc.voiceTools", "to": "lib.navManifest", "transport": "call", "label": "resolveNavCommand", "payload": "spoken target fuzzy-matched against NAV_COMMANDS aliases (ui_navigate)" },
{ "from": "svc.voiceTools", "to": "svc.voiceClient", "transport": "socket", "label": "UI action events", "payload": "navigation / UI action requests executed by the client" },
- { "from": "svc.voicePipeline", "to": "ext.tts", "transport": "spawn", "label": "synthesize", "payload": "reply sentences → WAV audio via piper/kokoro" },
+ { "from": "svc.voicePipeline", "to": "ext.tts", "transport": "spawn", "label": "synthesize", "payload": "reply sentences → WAV audio via Piper/Qwen3" },
{ "from": "svc.voicePipeline", "to": "svc.voiceClient", "transport": "socket", "label": "voice:tts:audio", "payload": "{ sentence, wav } frames played back as they arrive" }
]
},
diff --git a/data.reference/settings.json b/data.reference/settings.json
index c524f769d1..aadbe6fcd9 100644
--- a/data.reference/settings.json
+++ b/data.reference/settings.json
@@ -14,13 +14,8 @@
"vocabularyPrompt": ""
},
"tts": {
- "engine": "kokoro",
+ "engine": "piper",
"rate": 1.0,
- "kokoro": {
- "modelId": "onnx-community/Kokoro-82M-v1.0-ONNX",
- "dtype": "q8",
- "voice": "af_heart"
- },
"piper": {
"voice": "en_GB-jenny_dioco-medium",
"voicePath": "~/.portos/voice/voices/en_GB-jenny_dioco-medium.onnx",
diff --git a/docs/features/voice.md b/docs/features/voice.md
index 6d6ec272ef..471d10aafc 100644
--- a/docs/features/voice.md
+++ b/docs/features/voice.md
@@ -10,7 +10,7 @@ PortOS includes an optional voice assistant with support for fully local operati
|-------|----------------|--------------|--------|
| Speech-to-text | Browser [Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API) (default — **note**: Chromium browsers forward audio to a vendor cloud speech service) or [whisper.cpp](https://github.com/ggerganov/whisper.cpp) via `whisper-server` (HTTP :5562, fully local) | — | ✅ (whisper) / ⚠️ (web-speech) |
| LLM | LM Studio (`/v1/chat/completions`) | OpenAI-compatible local server | ✅ |
-| Text-to-speech | [Kokoro-82M](https://huggingface.co/onnx-community/Kokoro-82M-v1.0-ONNX) via `kokoro-js` (in-process) | [Piper](https://github.com/rhasspy/piper) (CLI) | ✅ |
+| Text-to-speech | [Piper](https://github.com/rhasspy/piper) (CLI) | Qwen3-TTS | ✅ |
| Voice activity | AudioWorklet + RMS VAD (hands-free) or `MediaRecorder` (push-to-talk) — Web Speech mode bypasses server audio and posts final text via `voice:text` | — | ✅ |
The TTS engine is selectable in **Settings → Voice → TTS engine**.
@@ -87,7 +87,7 @@ call rings unanswered and a `medium` notification records the miss instead of
silently dropping it. Quiet hours change only the greeting's tone, never
whether the call is picked up — you placed it, so PortOS answers at any hour.
Once answered, the call runs exactly like an outbound one: whisper STT →
-voice LLM/persona → Kokoro/Piper TTS, the same silence/max-duration/hangup
+voice LLM/persona → Piper/Qwen3 TTS, the same silence/max-duration/hangup
rules, and a transcript in the daily journal. If the Persistent Mind is
running, the call carries its persona and context and the transcript is
handed back to it as a message on hangup, continuing the same conversation on
@@ -124,16 +124,14 @@ device and the same host tab, so starting one while the other is active on
this tab is refused with a specific reason rather than fighting over the
device.
-### Why Kokoro is the default
+### Default TTS engine
-Kokoro is a 82M-parameter frontier TTS model that runs in-process via ONNX Runtime + transformers.js — **no Python, no extra binaries, cross-platform**. Quality is significantly higher than Piper (more natural prosody, expressive pacing). First synthesis after server start has a 2–3 s cold start as the model loads; warm calls are 200–500 ms per sentence on CPU.
-
-Use **Piper** instead if you need lower latency per call (~100 ms cold start), are on a memory-constrained machine, or want a particular pre-trained voice from rhasspy's catalogue.
+Piper is the default local TTS engine. Kokoro is retired: existing settings migrate to Piper while preserving custom Piper voices. Upgraded installs wait for **Save & Reconcile** before installing Piper. Existing Kokoro character profiles remain available as historical records; select or promote a Piper replacement to synthesize new audio.
## First-time setup
1. Open PortOS → **Settings → Voice**.
-2. Pick your TTS engine (default: Kokoro), Whisper model size, and CoreML toggle (macOS).
+2. Pick your TTS engine (default: Piper), Whisper model size, and CoreML toggle (macOS).
3. Toggle **Enable voice mode** and click **Save & Reconcile**.
PortOS will:
@@ -143,12 +141,12 @@ PortOS will:
- If Piper is selected, download the pre-built Piper binary + phonemize libs from [rhasspy/piper](https://github.com/rhasspy/piper) and [rhasspy/piper-phonemize](https://github.com/rhasspy/piper-phonemize) GitHub Releases (Piper is not on Homebrew), then fetch the selected voice `.onnx` into `~/.portos/voice/voices/`
- Start `portos-whisper` under PM2
-Kokoro models live under `~/.cache/huggingface/hub/` and download lazily on first synthesis.
+Piper voice models live under `~/.portos/voice/voices/`.
You can also run the bootstrap script directly:
```bash
-TTS_ENGINE=kokoro INSTALL_COREML=1 bash scripts/setup-voice.sh
+TTS_ENGINE=piper INSTALL_COREML=1 bash scripts/setup-voice.sh
TTS_ENGINE=piper VOICE_NAME=en_US-ryan-high bash scripts/setup-voice.sh
MODEL_NAME=ggml-small.en.bin bash scripts/setup-voice.sh
```
@@ -164,11 +162,8 @@ All options live in `data/settings.json` under `voice` (Settings UI patches this
| `stt.model` | `base.en` | `tiny.en` · `base.en` · `small.en` · `medium.en` · `large-v3` |
| `stt.coreml` | `false` | Optional on macOS. Enable to use the CoreML encoder companion (requires a custom whisper.cpp build with `-DWHISPER_COREML=1`). |
| `stt.endpoint` | `http://127.0.0.1:5562` | whisper-server listen address (whisper engine only). |
-| `tts.engine` | `kokoro` | `kokoro` or `piper` |
+| `tts.engine` | `piper` | `piper` or `qwen3-tts` |
| `tts.rate` | `1.0` | Speech rate, 0.5–2.0 |
-| `tts.kokoro.voice` | `af_heart` | See [Kokoro voices](https://huggingface.co/onnx-community/Kokoro-82M-v1.0-ONNX) — A-grade are `af_heart`, `af_bella`. |
-| `tts.kokoro.dtype` | `q8` | `q4` · `q8` · `fp16` · `fp32` (size/quality trade-off) |
-| `tts.kokoro.modelId` | `onnx-community/Kokoro-82M-v1.0-ONNX` | HuggingFace repo id |
| `tts.piper.voice` | `en_GB-jenny_dioco-medium` | Piper voice id (path-encoded) |
| `tts.piper.voicePath` | `~/.portos/voice/voices/<voice>.onnx` | ONNX file location |
| `llm.model` | `auto` | `auto` picks first loaded LM Studio model |
@@ -215,7 +210,7 @@ browser mic → MediaRecorder (PTT) OR AudioWorklet + RMS VAD (hands-free)
→ Socket.IO 'voice:turn' (audio) OR 'voice:text' (Web Speech final)
→ whisper.cpp /inference (STT for audio path)
→ LM Studio /v1/chat (streaming) (LLM)
- → sentence-boundary TTS dispatch (Kokoro in-process | Piper CLI)
+ → sentence-boundary TTS dispatch (Piper CLI | Qwen3-TTS runtime)
→ Socket.IO 'voice:tts:audio' → Web Audio playback queue
```
@@ -254,8 +249,6 @@ reuses the same `voice:call:audio` PCM frames (`voice:capture:start` /
- **Whisper badge red** — `brew install whisper-cpp`, then `which whisper-server`.
- **CoreML missing** — re-run `INSTALL_COREML=1 bash scripts/setup-voice.sh` (or toggle voice off/on after enabling CoreML).
-- **Kokoro shows `lazy`** — model loads on first synthesis. Hit "Test voice" to warm it up.
-- **Kokoro slow on first call** — first call after server start downloads model (~80 MB for q8) and initializes the runtime. Subsequent calls are 200–500 ms.
- **Piper spawn fails** — `which piper` and check voice file at `~/.portos/voice/voices/<name>.onnx`.
- **LM Studio red** — start LM Studio and load a chat model; the voice pipeline uses `/v1/chat/completions`.
- **No audio playback** — browsers require a user gesture before AudioContext can play. Click the page once or press the mic button.
@@ -264,8 +257,6 @@ reuses the same `voice:call:audio` PCM frames (`voice:capture:start` /
| Engine | Cold start | Warm latency (per sentence) | Quality |
|--------|------------|------------------------------|---------|
-| Kokoro q8 (CPU) | 2–3 s | 200–500 ms | High |
-| Kokoro fp32 (CPU) | 3–5 s | 400–900 ms | Highest |
| Piper | ~100 ms (CLI spawn) | ~100 ms | Mid |
| Whisper base.en (no CoreML) | 0 (server resident) | 400–800 ms / 2 s of audio | Good |
| Whisper base.en + CoreML | 0 | 150–300 ms / 2 s of audio | Good |
diff --git a/scripts/migrations/376-retire-kokoro-tts.test.js b/scripts/migrations/376-retire-kokoro-tts.test.js
index 880677c1f0..4ea948b919 100644
--- a/scripts/migrations/376-retire-kokoro-tts.test.js
+++ b/scripts/migrations/376-retire-kokoro-tts.test.js
@@ -42,3 +42,16 @@ describe('retire Kokoro settings migration', () => {
await expect(migration.up({ rootDir })).rejects.toThrow();
});
});
+
+it('keeps a fresh settings seed on Piper without an upgrade marker', async () => {
+ const rootDir = await mkdtemp(join(tmpdir(), 'piper-fresh-'));
+ roots.push(rootDir);
+ await mkdir(join(rootDir, 'data'));
+ const path = join(rootDir, 'data/settings.json');
+ const seed = await readFile(new URL('../../data.reference/settings.json', import.meta.url), 'utf8');
+ await writeFile(path, seed);
+ await migration.up({ rootDir });
+ const settings = JSON.parse(await readFile(path, 'utf8'));
+ expect(settings.voice.tts.engine).toBe('piper');
+ expect(settings.voice.tts).not.toHaveProperty('retiredEngine');
+});
diff --git a/scripts/trusted-rebuilds.test.js b/scripts/trusted-rebuilds.test.js
index d8baa64aa9..5366992027 100644
--- a/scripts/trusted-rebuilds.test.js
+++ b/scripts/trusted-rebuilds.test.js
@@ -189,7 +189,8 @@ describe('trusted rebuild allowlist', () => {
const hooked = packagesWithInstallHooks('server');
expect(hooked, 'scan returned null even though server/node_modules exists — it is looking at the wrong path').not.toBeNull();
expect(hooked.has('node-pty'), 'scan did not find node-pty — it declares install+postinstall').toBe(true);
- expect(hooked.size).toBeGreaterThanOrEqual(3);
+ // node-pty is the cross-platform non-vacuity witness. Retiring Kokoro
+ // removes its hooked transitive dependencies; Windows can have only this one.
});
// The lockfile-driven twin of the test below. This one runs in EVERY CI job for
diff --git a/server/routes/voice.js b/server/routes/voice.js
index c0fb527d60..9ff54830f9 100644
--- a/server/routes/voice.js
+++ b/server/routes/voice.js
@@ -146,9 +146,12 @@ router.put('/config', asyncHandler(async (req, res) => {
{ status: 400, code: 'VALIDATION_ERROR' },
);
}
- const next = await updateVoiceConfig(parsed.data);
+ let next = await updateVoiceConfig(parsed.data);
invalidateHealthCache();
const reconciliation = await reconcile(next).catch((err) => ({ error: err.message }));
+ if (next.enabled && next.tts?.retiredEngine && !reconciliation?.error && !reconciliation?.setupRequired) {
+ next = await updateVoiceConfig({ tts: { retiredEngine: null } });
+ }
req.app.get('io')?.emit('voice:config:changed', {
enabled: next.enabled,
sttEngine: next.stt?.engine,
diff --git a/server/routes/voice.test.js b/server/routes/voice.test.js
index 3c740ec428..2ac865afdd 100644
--- a/server/routes/voice.test.js
+++ b/server/routes/voice.test.js
@@ -358,6 +358,23 @@ describe('Voice Routes', () => {
expect(config.updateVoiceConfig).not.toHaveBeenCalled();
});
+ it.each([
+ [true, {}, true],
+ [true, { error: 'setup failed' }, false],
+ [false, { skipped: true }, false],
+ ])('clears retirement only after enabled successful reconciliation (%s, %j)', async (enabled, result, cleared) => {
+ const migrated = { enabled, tts: { engine: 'piper', retiredEngine: 'kokoro' } };
+ const settled = { enabled, tts: { engine: 'piper' } };
+ config.updateVoiceConfig.mockReset();
+ config.updateVoiceConfig.mockResolvedValueOnce(migrated).mockResolvedValueOnce(settled);
+ bootstrap.reconcile.mockResolvedValue(result);
+ const res = await request(buildApp()).put('/api/voice/config').send({ enabled });
+ expect(res.status).toBe(200);
+ expect(config.updateVoiceConfig).toHaveBeenCalledTimes(cleared ? 2 : 1);
+ expect(res.body.config).toEqual(cleared ? settled : migrated);
+ if (cleared) expect(config.updateVoiceConfig).toHaveBeenLastCalledWith({ tts: { retiredEngine: null } });
+ });
+
it('reports reconcile failures without 500-ing the route', async () => {
config.updateVoiceConfig.mockResolvedValue({ ...DEFAULT_CFG, enabled: true });
bootstrap.reconcile.mockRejectedValue(new Error('whisper-server not on PATH'));
diff --git a/server/services/voice/bootstrap.js b/server/services/voice/bootstrap.js
index eae8019339..eba159c0da 100644
--- a/server/services/voice/bootstrap.js
+++ b/server/services/voice/bootstrap.js
@@ -407,6 +407,13 @@ export const reconcile = async (cfg, { allowSetup = true } = {}) => {
const bins = await verifyBinaries(cfg);
const models = verifyModels(cfg);
if (bins.piperRequired && (!bins.piper || !models.ttsVoice)) {
+ // Keep an already-provisioned speech recognizer available while TTS
+ // waits for consent. No setup scripts or LLM preloads run on this path.
+ if (cfg.stt?.engine === 'web-speech') {
+ await stopWhisper().catch(() => null);
+ } else if (bins.whisper && models.sttModel && (!cfg.stt.coreml || models.coreml)) {
+ return { ...await startWhisper(cfg), setupRequired: 'piper' };
+ }
return { setupRequired: 'piper' };
}
}
diff --git a/server/services/voice/bootstrap.retirement.test.js b/server/services/voice/bootstrap.retirement.test.js
index 8bb6fef383..e823ee5b4b 100644
--- a/server/services/voice/bootstrap.retirement.test.js
+++ b/server/services/voice/bootstrap.retirement.test.js
@@ -2,12 +2,25 @@ import { expect, it, vi } from 'vitest';
vi.mock('fs', () => ({ existsSync: vi.fn(() => false) }));
vi.mock('../../lib/processEnv.js', () => ({ whichFirst: vi.fn(async () => null) }));
-vi.mock('../pm2.js', () => ({ execPm2: vi.fn(), getAppStatus: vi.fn() }));
+vi.mock('../pm2.js', () => ({ execPm2: vi.fn(async () => ({})), getAppStatus: vi.fn(async () => null) }));
+vi.mock('../../lib/fetchWithTimeout.js', () => ({ fetchWithTimeout: vi.fn(async () => ({})) }));
+vi.mock('net', () => ({ createServer: () => {
+ const handlers = {};
+ const server = {
+ once: (event, callback) => { handlers[event] = callback; },
+ listen: () => { handlers.listening(); },
+ close: (callback) => { callback?.(); },
+ };
+ return server;
+} }));
vi.mock('./llm.js', () => ({ isToolCapable: vi.fn(), isReasoningModel: vi.fn() }));
vi.mock('../providers.js', () => ({ getProviderById: vi.fn() }));
vi.mock('../../lib/childProcess.js', () => ({ execFile: vi.fn() }));
vi.mock('../settings.js', () => ({ getSettings: vi.fn(), updateSettings: vi.fn() }));
+import { existsSync } from 'fs';
+import { whichFirst } from '../../lib/processEnv.js';
+import { execPm2 } from '../pm2.js';
import { execFile } from '../../lib/childProcess.js';
import { getProviderById } from '../providers.js';
import { VOICE_DEFAULTS } from './config.js';
@@ -19,3 +32,17 @@ it('does not download or preload anything when an upgraded install boots before
expect(execFile).not.toHaveBeenCalled();
expect(getProviderById).not.toHaveBeenCalled();
});
+
+it('starts provisioned Whisper while deferring missing Piper setup and LLM preload at upgrade boot', async () => {
+ vi.clearAllMocks();
+ existsSync.mockImplementation(path => String(path).endsWith('.bin'));
+ whichFirst.mockImplementation(async bin => bin === 'whisper-server' ? '/usr/bin/whisper-server' : null);
+ const cfg = { ...VOICE_DEFAULTS, enabled: true,
+ stt: { ...VOICE_DEFAULTS.stt, engine: 'whisper' },
+ tts: { ...VOICE_DEFAULTS.tts, retiredEngine: 'kokoro' } };
+ const result = await reconcile(cfg, { allowSetup: false });
+ expect(result).toMatchObject({ name: 'portos-whisper', setupRequired: 'piper' });
+ expect(execPm2).toHaveBeenCalledWith(expect.arrayContaining(['start', '/usr/bin/whisper-server']));
+ expect(execFile).not.toHaveBeenCalled();
+ expect(getProviderById).not.toHaveBeenCalled();
+});
diff --git a/server/services/voice/config.js b/server/services/voice/config.js
index eb77fae3dd..1552a0dc5c 100644
--- a/server/services/voice/config.js
+++ b/server/services/voice/config.js
@@ -182,6 +182,7 @@ export const updateVoiceConfig = async (patch) => {
const current = deepMerge(VOICE_DEFAULTS, settings.voice || {});
const next = deepMerge(current, patch || {});
next.tts = migrateRetiredTtsConfig(next.tts);
+ if (next.tts.retiredEngine === null) delete next.tts.retiredEngine;
await updateSettings({ voice: next });
cachedConfig = next;
return next;
diff --git a/server/services/voice/config.test.js b/server/services/voice/config.test.js
index e9833121e6..d1448eb379 100644
--- a/server/services/voice/config.test.js
+++ b/server/services/voice/config.test.js
@@ -26,3 +26,13 @@ describe('voice configuration defaults', () => {
});
});
});
+
+it('persists retirement acknowledgement without removing customized TTS settings', async () => {
+ const tts = { engine: 'piper', retiredEngine: 'kokoro', rate: 1.3, piper: { voice: 'custom', voicePath: '~/custom.onnx' } };
+ getSettings.mockResolvedValue({ voice: { enabled: true, tts } });
+ const saved = await updateVoiceConfig({ tts: { retiredEngine: null } });
+ expect(saved.tts).not.toHaveProperty('retiredEngine');
+ expect(saved.tts).toMatchObject({ engine: 'piper', rate: 1.3, piper: tts.piper });
+ expect(updateSettings).toHaveBeenCalledWith({ voice: saved });
+ expect(await getVoiceConfig()).toBe(saved);
+});