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
+21 -5
View File
@@ -22,10 +22,14 @@ export interface BridgeConfig {
requestTimeoutMs: number;
};
stt: {
provider: 'none' | 'openai-compatible';
provider: 'none' | 'builtin' | 'openai-compatible';
baseUrl: string;
apiKey: string;
/** Hub model id for `builtin`; provider model name for `openai-compatible`. */
model: string;
/** `builtin` only: weight precision and where model files are cached. */
dtype: string;
cacheDir: string;
};
limits: {
captureMaxSeconds: number;
@@ -122,9 +126,19 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): BridgeConfig {
if (parsed.origin !== origin) throw new ConfigError(`HERMEVEN_ALLOWED_ORIGINS entry must be scheme://host[:port]: ${origin}`);
}
const sttProvider = (env.STT_PROVIDER || 'none') as BridgeConfig['stt']['provider'];
if (sttProvider !== 'none' && sttProvider !== 'openai-compatible') {
throw new ConfigError('STT_PROVIDER must be "none" or "openai-compatible"');
// Built-in Whisper is the default: voice works with no provider account and no audio
// leaving the bridge host.
const sttProvider = (env.STT_PROVIDER || 'builtin') as BridgeConfig['stt']['provider'];
if (sttProvider !== 'none' && sttProvider !== 'builtin' && sttProvider !== 'openai-compatible') {
throw new ConfigError('STT_PROVIDER must be "builtin", "openai-compatible" or "none"');
}
const sttModel = env.STT_MODEL || (sttProvider === 'builtin' ? 'onnx-community/whisper-base' : '');
if (sttProvider === 'builtin' && !/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(sttModel)) {
throw new ConfigError('STT_MODEL must be a Hugging Face model id such as onnx-community/whisper-base');
}
const sttDtype = env.STT_DTYPE || 'q8';
if (!['q8', 'q4', 'fp32', 'fp16', 'int8', 'uint8'].includes(sttDtype)) {
throw new ConfigError('STT_DTYPE must be one of q8, q4, fp32, fp16, int8, uint8');
}
let sttBaseUrl = '';
if (sttProvider === 'openai-compatible') {
@@ -154,7 +168,9 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): BridgeConfig {
provider: sttProvider,
baseUrl: sttBaseUrl,
apiKey: env.STT_API_KEY || '',
model: env.STT_MODEL || '',
model: sttModel,
dtype: sttDtype,
cacheDir: env.STT_CACHE_DIR || './data/models',
},
limits: {
captureMaxSeconds,