Add wakeword support

This commit is contained in:
James Babcock committed 2026-07-19 20:45:51 -07:00
1 parent 4401a4a416
commit 161dbd104e
11 files changed
+315 -13

No files matched your search

+13
View File
@@ -75,6 +75,19 @@ export type RawInputEvent =
eventSource: number;
systemExitReasonCode: number;
frameId: number;
}
| {
/**
* Stock Even AI app (sid 0x07), not EvenHub. `eventType` carries
* eEvenAIStatus -- see EvenAIStatus in app/g2/events.ts. The only one we
* act on is EVEN_AI_WAKE_UP, i.e. the "Hey Even" wakeword.
*/
kind: "even-ai";
containerName: string;
eventType: number;
eventSource: number;
systemExitReasonCode: number;
frameId: number;
};
function nonNegativeNumber(value: number): number {
+22
View File
@@ -25,6 +25,12 @@ export type PushToTalkOptions = {
provider: VoiceProviderKind;
elevenLabsApiKey: string;
saveRecording: boolean;
/**
* Watch the mic and fire onSpeechEnd when the speaker stops. For hands-free
* ("Hey Even") capture, which has no button release to end the utterance.
* Ignored when the mic is already running for another holder.
*/
endpointing?: boolean;
};
/** Who currently wants the mic running. */
@@ -34,6 +40,7 @@ export class FaceclawVoiceControlBridge {
private readonly statusListeners = new Set<(state: VoiceControlState) => void>();
private readonly wakeWordListeners = new Set<(keyword: string) => void>();
private readonly transcriptListeners = new Set<(event: VoiceTranscriptEvent) => void>();
private readonly speechEndListeners = new Set<() => void>();
private controller: any | null = null;
private listenerProxy: any | null = null;
private status = "Voice control stopped.";
@@ -62,6 +69,15 @@ export class FaceclawVoiceControlBridge {
return () => this.transcriptListeners.delete(listener);
}
/**
* The speaker stopped, in a hands-free session. Only fires when the capture
* was started with `endpointing: true`.
*/
onSpeechEnd(listener: () => void): () => void {
this.speechEndListeners.add(listener);
return () => this.speechEndListeners.delete(listener);
}
/** Begin push-to-talk capture (momentary; released with stopPushToTalk). */
startPushToTalk(options: PushToTalkOptions): void {
this.acquireCapture("ptt", options);
@@ -93,6 +109,7 @@ export class FaceclawVoiceControlBridge {
this.ensureController();
this.controller?.setCommunicator(options.communicator);
this.controller?.setSaveRecordings(options.saveRecording);
this.controller?.setEndpointing(Boolean(options.endpointing));
if (options.provider === "elevenlabs" && options.elevenLabsApiKey.trim()) {
this.cloudClient = new ElevenLabsSttClient({
@@ -174,6 +191,11 @@ export class FaceclawVoiceControlBridge {
onPcm: (pcm: any) => {
this.cloudClient?.acceptPcm(toUint8Array(pcm));
},
onSpeechEnd: () => {
for (const listener of this.speechEndListeners) {
listener();
}
},
});
this.controller.setListener(this.listenerProxy);
}