Files
EveFlow/tests/vad.test.ts
T
Claude 127a2083a1 feat!: rebuild EveFlow as a JARVIS-style voice HUD for Hermes Agent (v2.0.0)
Complete rewrite of the application:

- Toolchain: Electron 44, Vite 8, React 19, TypeScript 5.9, Zustand, Vitest;
  main process rewritten in TypeScript (electron/), typed IPC contract (shared/),
  sandboxed renderer with webSecurity on and an HTTP/SSE proxy in the main process.
- Voice: AudioWorklet microphone capture at 16 kHz with adaptive energy VAD and
  auto-stop, WAV encoder, OpenAI-compatible STT, TTS queue with sentence-level
  streaming, prefetch and Web Audio playback feeding an analyser; hands-free mode,
  global push-to-talk hotkey, system-voice fallback.
- Hermes: full API client (capabilities, health, models, skills, toolsets,
  sessions, jobs) with automatic transport selection: runs API (SSE lifecycle,
  approvals, steer, stop) > sessions stream > chat completions with local tools;
  tolerant event normalisation; webhook receiver hardened (secret, size limit).
- UI: JARVIS arc-reactor core on Canvas 2D reacting to the real audio signal,
  holographic HUD layout (transcript, core, Hermes ops panel with tools/crons/
  skills/sessions/link tabs, telemetry), settings drawer, approval modals,
  compact floating widget, four themes, tray icon and global shortcuts.
- Removed the 3D Eve robot, three.js and legacy assets; migrated 1.x settings.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Wn5VX9HNbJ7N54hR24u9Y
2026-09-03 13:40:59 +00:00

28 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { EnergyVad } from '../src/services/voice/vad';
const feed = (vad: EnergyVad, rms: number, ms: number, step = 64): string[] => {
const out: string[] = [];
for (let t = 0; t < ms; t += step) out.push(vad.feed(rms, step));
return out;
};
describe('EnergyVad', () => {
it('detects start and end of speech after silence', () => {
const vad = new EnergyVad({ silenceMs: 500, minSpeechMs: 200 });
expect(new Set(feed(vad, 0.003, 600))).toEqual(new Set(['idle']));
expect(feed(vad, 0.2, 800)).toContain('speech-start');
expect(feed(vad, 0.003, 700)).toContain('speech-end');
expect(vad.isSpeaking).toBe(false);
});
it('reports too-short bursts and no-speech timeouts', () => {
const vad = new EnergyVad({ silenceMs: 300, minSpeechMs: 400, noSpeechTimeoutMs: 20000 });
feed(vad, 0.003, 500);
feed(vad, 0.3, 150);
expect(feed(vad, 0.003, 400)).toContain('too-short');
const quiet = new EnergyVad({ noSpeechTimeoutMs: 1000 });
expect(feed(quiet, 0.002, 1200)).toContain('no-speech');
});
});