pi-voicekit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +341 -0
- package/extensions/voice/config.ts +395 -0
- package/extensions/voice/deepgram.ts +33 -0
- package/extensions/voice/device.ts +382 -0
- package/extensions/voice/hold-to-talk.ts +69 -0
- package/extensions/voice/local.ts +1143 -0
- package/extensions/voice/model-download.ts +636 -0
- package/extensions/voice/onboarding.ts +739 -0
- package/extensions/voice/release-controller.ts +55 -0
- package/extensions/voice/settings-panel.ts +1602 -0
- package/extensions/voice/sherpa-engine.ts +464 -0
- package/extensions/voice/sherpa-loader.ts +143 -0
- package/extensions/voice/sherpa-onnx-node.d.ts +4 -0
- package/extensions/voice/speak.ts +430 -0
- package/extensions/voice/tts-deepgram.ts +454 -0
- package/extensions/voice/tts-engine.ts +653 -0
- package/extensions/voice/tts-install-progress.ts +257 -0
- package/extensions/voice/tts-local-models.ts +1255 -0
- package/extensions/voice/tts-onboarding-overlay.ts +186 -0
- package/extensions/voice/tts-onboarding.ts +87 -0
- package/extensions/voice/tts-playback-indicator.ts +127 -0
- package/extensions/voice/tts-playback.ts +675 -0
- package/extensions/voice/tts-text-filter.ts +404 -0
- package/extensions/voice/ui-aura.ts +272 -0
- package/extensions/voice/ui-help-overlay.ts +161 -0
- package/extensions/voice/ui-icons.ts +124 -0
- package/extensions/voice/ui-locale-labels.ts +110 -0
- package/extensions/voice/ui-picker.ts +209 -0
- package/extensions/voice/ui-render-ticker.ts +171 -0
- package/extensions/voice/ui-widget-base.ts +219 -0
- package/extensions/voice/ui-width.ts +112 -0
- package/extensions/voice.ts +3644 -0
- package/package.json +75 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gap-based release-deadline timer for hold-to-talk (non-kitty terminals).
|
|
3
|
+
*
|
|
4
|
+
* Extracted from voice.ts so the re-arm lifetime — the #13 fix core — is
|
|
5
|
+
* testable against a fake clock. voice.ts maps resetReleaseDetect /
|
|
6
|
+
* clearReleaseTimer / onSpaceReleaseDetected directly onto this class.
|
|
7
|
+
*
|
|
8
|
+
* Semantics: a single-shot deadline that resets on every arm(). It fires
|
|
9
|
+
* exactly once when the configured interval elapses without a fresh arm() —
|
|
10
|
+
* i.e. a key-repeat gap means "the user released the key".
|
|
11
|
+
*/
|
|
12
|
+
export interface TimerPort {
|
|
13
|
+
/** Arm a one-shot that fires `fn` after `ms`; returns a cancel handle. */
|
|
14
|
+
once(fn: () => void, ms: number): { cancel(): void };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface GapTimerOptions {
|
|
18
|
+
/** Deadline in ms — reset on every arm(). */
|
|
19
|
+
ms: number;
|
|
20
|
+
/** Called exactly once when the deadline elapses without re-arm. */
|
|
21
|
+
onFire: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class GapTimer {
|
|
25
|
+
private cancelFn: (() => void) | null = null;
|
|
26
|
+
private readonly port: TimerPort;
|
|
27
|
+
private readonly ms: number;
|
|
28
|
+
private readonly onFire: () => void;
|
|
29
|
+
|
|
30
|
+
constructor(port: TimerPort, opts: GapTimerOptions) {
|
|
31
|
+
this.port = port;
|
|
32
|
+
this.ms = opts.ms;
|
|
33
|
+
this.onFire = opts.onFire;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Arm (or re-arm) the release-deadline. */
|
|
37
|
+
arm(): void {
|
|
38
|
+
this.cancel();
|
|
39
|
+
const handle = this.port.once(() => {
|
|
40
|
+
this.cancelFn = null;
|
|
41
|
+
this.onFire();
|
|
42
|
+
}, this.ms);
|
|
43
|
+
this.cancelFn = handle.cancel;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Cancel any pending deadline. Safe to call when not armed. */
|
|
47
|
+
cancel(): void {
|
|
48
|
+
this.cancelFn?.();
|
|
49
|
+
this.cancelFn = null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get active(): boolean {
|
|
53
|
+
return this.cancelFn != null;
|
|
54
|
+
}
|
|
55
|
+
}
|