Build speech-to-text into the bridge; add droplet deployment examples

STT_PROVIDER now defaults to "builtin": Whisper (onnx-community/whisper-base,
q8) runs in the bridge process on the CPU via @huggingface/transformers, so
no provider account is needed and recordings stay on the bridge host. Silent
captures are detected by level before the model runs. The external
OpenAI-compatible adapter remains available.

Tests: 130 unit/integration; 4 scenarios with the real model on a real
speech recording (npm run test:real-stt). Not tested on audio from the
glasses or on a droplet.

deploy/ and docs/deploy-droplet.md are examples that have not been run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-18 18:31:30 -08:00
co-authored by Claude Fable 5.2
parent 3c9e094977
commit 6d74f9e121
29 changed files with 1602 additions and 42 deletions
+12
View File
@@ -1,6 +1,7 @@
import { LOG_REDACT, createBridge } from './app.ts';
import { ConfigError, loadConfig } from './config.ts';
import { loadEnvFile } from './env.ts';
import { BuiltinWhisperStt } from './stt/builtinWhisper.ts';
async function main(): Promise<void> {
loadEnvFile();
@@ -10,6 +11,17 @@ async function main(): Promise<void> {
});
await bridge.app.listen({ host: config.host, port: config.port });
// Load the built-in speech model in the background so the first spoken question is not
// slowed by it. On a first start this downloads the model files.
if (bridge.stt instanceof BuiltinWhisperStt) {
const started = Date.now();
bridge.app.log.info({ model: config.stt.model, dtype: config.stt.dtype }, 'stt.loading');
bridge.stt.warm().then(
() => bridge.app.log.info({ load_ms: Date.now() - started }, 'stt.ready'),
() => bridge.app.log.error({ model: config.stt.model }, 'stt.load_failed'),
);
}
let closing = false;
const stop = (signal: string) => {
if (closing) return;