even-toolkit 1.0.1 → 1.1.1
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/dist/stt/audio/buffer.d.ts +12 -0
- package/dist/stt/audio/buffer.d.ts.map +1 -0
- package/dist/stt/audio/buffer.js +35 -0
- package/dist/stt/audio/buffer.js.map +1 -0
- package/dist/stt/audio/pcm-utils.d.ts +9 -0
- package/dist/stt/audio/pcm-utils.d.ts.map +1 -0
- package/dist/stt/audio/pcm-utils.js +52 -0
- package/dist/stt/audio/pcm-utils.js.map +1 -0
- package/dist/stt/audio/resample.d.ts +3 -0
- package/dist/stt/audio/resample.d.ts.map +1 -0
- package/dist/stt/audio/resample.js +17 -0
- package/dist/stt/audio/resample.js.map +1 -0
- package/dist/stt/audio/vad.d.ts +17 -0
- package/dist/stt/audio/vad.d.ts.map +1 -0
- package/dist/stt/audio/vad.js +43 -0
- package/dist/stt/audio/vad.js.map +1 -0
- package/dist/stt/engine.d.ts +38 -0
- package/dist/stt/engine.d.ts.map +1 -0
- package/dist/stt/engine.js +233 -0
- package/dist/stt/engine.js.map +1 -0
- package/dist/stt/i18n.d.ts +13 -0
- package/dist/stt/i18n.d.ts.map +1 -0
- package/dist/stt/i18n.js +31 -0
- package/dist/stt/i18n.js.map +1 -0
- package/dist/stt/index.d.ts +11 -0
- package/dist/stt/index.d.ts.map +1 -0
- package/dist/stt/index.js +11 -0
- package/dist/stt/index.js.map +1 -0
- package/dist/stt/providers/deepgram.d.ts +29 -0
- package/dist/stt/providers/deepgram.d.ts.map +1 -0
- package/dist/stt/providers/deepgram.js +145 -0
- package/dist/stt/providers/deepgram.js.map +1 -0
- package/dist/stt/providers/web-speech.d.ts +25 -0
- package/dist/stt/providers/web-speech.d.ts.map +1 -0
- package/dist/stt/providers/web-speech.js +153 -0
- package/dist/stt/providers/web-speech.js.map +1 -0
- package/dist/stt/providers/whisper-api.d.ts +26 -0
- package/dist/stt/providers/whisper-api.d.ts.map +1 -0
- package/dist/stt/providers/whisper-api.js +120 -0
- package/dist/stt/providers/whisper-api.js.map +1 -0
- package/dist/stt/providers/whisper-local/provider.d.ts +31 -0
- package/dist/stt/providers/whisper-local/provider.d.ts.map +1 -0
- package/dist/stt/providers/whisper-local/provider.js +174 -0
- package/dist/stt/providers/whisper-local/provider.js.map +1 -0
- package/dist/stt/providers/whisper-local/worker.d.ts +2 -0
- package/dist/stt/providers/whisper-local/worker.d.ts.map +1 -0
- package/dist/stt/providers/whisper-local/worker.js +35 -0
- package/dist/stt/providers/whisper-local/worker.js.map +1 -0
- package/dist/stt/react/useSTT.d.ts +3 -0
- package/dist/stt/react/useSTT.d.ts.map +1 -0
- package/dist/stt/react/useSTT.js +99 -0
- package/dist/stt/react/useSTT.js.map +1 -0
- package/dist/stt/registry.d.ts +3 -0
- package/dist/stt/registry.d.ts.map +1 -0
- package/dist/stt/registry.js +23 -0
- package/dist/stt/registry.js.map +1 -0
- package/dist/stt/sources/glass-bridge.d.ts +28 -0
- package/dist/stt/sources/glass-bridge.d.ts.map +1 -0
- package/dist/stt/sources/glass-bridge.js +47 -0
- package/dist/stt/sources/glass-bridge.js.map +1 -0
- package/dist/stt/sources/microphone.d.ts +17 -0
- package/dist/stt/sources/microphone.d.ts.map +1 -0
- package/dist/stt/sources/microphone.js +69 -0
- package/dist/stt/sources/microphone.js.map +1 -0
- package/dist/stt/types.d.ts +89 -0
- package/dist/stt/types.d.ts.map +1 -0
- package/dist/stt/types.js +3 -0
- package/dist/stt/types.js.map +1 -0
- package/glasses/action-bar.ts +57 -0
- package/glasses/action-map.ts +41 -0
- package/glasses/bridge.ts +306 -0
- package/glasses/canvas-renderer.ts +86 -0
- package/glasses/composer.ts +69 -0
- package/glasses/gestures.ts +60 -0
- package/glasses/index.ts +10 -0
- package/glasses/keep-alive.ts +30 -0
- package/glasses/keyboard.ts +64 -0
- package/glasses/layout.ts +121 -0
- package/glasses/paginate-text.ts +85 -0
- package/glasses/png-utils.ts +97 -0
- package/glasses/splash.ts +298 -0
- package/glasses/text-clean.ts +38 -0
- package/glasses/text-utils.ts +50 -0
- package/glasses/timer-display.ts +91 -0
- package/glasses/types.ts +59 -0
- package/glasses/upng.d.ts +19 -0
- package/glasses/useFlashPhase.ts +30 -0
- package/glasses/useGlasses.ts +214 -0
- package/package.json +42 -3
- package/stt/audio/buffer.ts +40 -0
- package/stt/audio/pcm-utils.ts +60 -0
- package/stt/audio/resample.ts +18 -0
- package/stt/audio/vad.ts +61 -0
- package/stt/engine.ts +274 -0
- package/stt/i18n.ts +39 -0
- package/stt/index.ts +10 -0
- package/stt/providers/deepgram.ts +178 -0
- package/stt/providers/web-speech.ts +221 -0
- package/stt/providers/whisper-api.ts +146 -0
- package/stt/providers/whisper-local/provider.ts +226 -0
- package/stt/providers/whisper-local/worker.ts +40 -0
- package/stt/react/useSTT.ts +113 -0
- package/stt/registry.ts +24 -0
- package/stt/sources/glass-bridge.ts +67 -0
- package/stt/sources/microphone.ts +75 -0
- package/stt/types.ts +104 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Audio accumulator — collects Float32 chunks and exports as WAV */
|
|
2
|
+
export declare function createAudioBuffer(config?: {
|
|
3
|
+
maxSeconds?: number;
|
|
4
|
+
sampleRate?: number;
|
|
5
|
+
}): {
|
|
6
|
+
append: (chunk: Float32Array) => void;
|
|
7
|
+
getAll: () => Float32Array;
|
|
8
|
+
getWav: () => Blob;
|
|
9
|
+
clear: () => void;
|
|
10
|
+
duration: () => number;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../stt/audio/buffer.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;oBAM9D,YAAY,KAAG,IAAI;kBAMvB,YAAY;kBAUZ,IAAI;iBAIL,IAAI;oBAKD,MAAM;EAK5B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { float32ToWav } from './pcm-utils';
|
|
2
|
+
/** Audio accumulator — collects Float32 chunks and exports as WAV */
|
|
3
|
+
export function createAudioBuffer(config) {
|
|
4
|
+
const sampleRate = config?.sampleRate ?? 16000;
|
|
5
|
+
const maxSamples = (config?.maxSeconds ?? 30) * sampleRate;
|
|
6
|
+
const chunks = [];
|
|
7
|
+
let totalSamples = 0;
|
|
8
|
+
function append(chunk) {
|
|
9
|
+
if (totalSamples + chunk.length > maxSamples)
|
|
10
|
+
return;
|
|
11
|
+
chunks.push(chunk);
|
|
12
|
+
totalSamples += chunk.length;
|
|
13
|
+
}
|
|
14
|
+
function getAll() {
|
|
15
|
+
const out = new Float32Array(totalSamples);
|
|
16
|
+
let offset = 0;
|
|
17
|
+
for (const chunk of chunks) {
|
|
18
|
+
out.set(chunk, offset);
|
|
19
|
+
offset += chunk.length;
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
function getWav() {
|
|
24
|
+
return float32ToWav(getAll(), sampleRate);
|
|
25
|
+
}
|
|
26
|
+
function clear() {
|
|
27
|
+
chunks.length = 0;
|
|
28
|
+
totalSamples = 0;
|
|
29
|
+
}
|
|
30
|
+
function duration() {
|
|
31
|
+
return totalSamples / sampleRate;
|
|
32
|
+
}
|
|
33
|
+
return { append, getAll, getWav, clear, duration };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../stt/audio/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,qEAAqE;AACrE,MAAM,UAAU,iBAAiB,CAAC,MAAqD;IACrF,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,KAAK,CAAC;IAC/C,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,UAAU,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC;IAC3D,MAAM,MAAM,GAAmB,EAAE,CAAC;IAClC,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,SAAS,MAAM,CAAC,KAAmB;QACjC,IAAI,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,UAAU;YAAE,OAAO;QACrD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnB,YAAY,IAAI,KAAK,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED,SAAS,MAAM;QACb,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3C,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACzB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,SAAS,MAAM;QACb,OAAO,YAAY,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS,KAAK;QACZ,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAClB,YAAY,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,SAAS,QAAQ;QACf,OAAO,YAAY,GAAG,UAAU,CAAC;IACnC,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Convert Uint8Array of 16-bit signed PCM to Int16Array */
|
|
2
|
+
export declare function uint8ToPcm16(data: Uint8Array): Int16Array;
|
|
3
|
+
/** Convert Int16Array PCM to Float32Array [-1, 1] */
|
|
4
|
+
export declare function pcm16ToFloat32(data: Int16Array): Float32Array;
|
|
5
|
+
/** Convert Float32Array [-1, 1] to Int16Array PCM */
|
|
6
|
+
export declare function float32ToPcm16(data: Float32Array): Int16Array;
|
|
7
|
+
/** Convert Float32Array to WAV Blob */
|
|
8
|
+
export declare function float32ToWav(data: Float32Array, sampleRate: number): Blob;
|
|
9
|
+
//# sourceMappingURL=pcm-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pcm-utils.d.ts","sourceRoot":"","sources":["../../../stt/audio/pcm-utils.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEzD;AAED,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY,CAM7D;AAED,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAO7D;AAED,uCAAuC;AACvC,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CA4BzE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Convert Uint8Array of 16-bit signed PCM to Int16Array */
|
|
2
|
+
export function uint8ToPcm16(data) {
|
|
3
|
+
return new Int16Array(data.buffer, data.byteOffset, data.byteLength / 2);
|
|
4
|
+
}
|
|
5
|
+
/** Convert Int16Array PCM to Float32Array [-1, 1] */
|
|
6
|
+
export function pcm16ToFloat32(data) {
|
|
7
|
+
const out = new Float32Array(data.length);
|
|
8
|
+
for (let i = 0; i < data.length; i++) {
|
|
9
|
+
out[i] = data[i] / 32768;
|
|
10
|
+
}
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
/** Convert Float32Array [-1, 1] to Int16Array PCM */
|
|
14
|
+
export function float32ToPcm16(data) {
|
|
15
|
+
const out = new Int16Array(data.length);
|
|
16
|
+
for (let i = 0; i < data.length; i++) {
|
|
17
|
+
const s = Math.max(-1, Math.min(1, data[i]));
|
|
18
|
+
out[i] = s < 0 ? s * 0x8000 : s * 0x7fff;
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
/** Convert Float32Array to WAV Blob */
|
|
23
|
+
export function float32ToWav(data, sampleRate) {
|
|
24
|
+
const pcm = float32ToPcm16(data);
|
|
25
|
+
const buffer = new ArrayBuffer(44 + pcm.byteLength);
|
|
26
|
+
const view = new DataView(buffer);
|
|
27
|
+
// RIFF header
|
|
28
|
+
writeString(view, 0, 'RIFF');
|
|
29
|
+
view.setUint32(4, 36 + pcm.byteLength, true);
|
|
30
|
+
writeString(view, 8, 'WAVE');
|
|
31
|
+
// fmt chunk
|
|
32
|
+
writeString(view, 12, 'fmt ');
|
|
33
|
+
view.setUint32(16, 16, true); // chunk size
|
|
34
|
+
view.setUint16(20, 1, true); // PCM format
|
|
35
|
+
view.setUint16(22, 1, true); // mono
|
|
36
|
+
view.setUint32(24, sampleRate, true); // sample rate
|
|
37
|
+
view.setUint32(28, sampleRate * 2, true); // byte rate
|
|
38
|
+
view.setUint16(32, 2, true); // block align
|
|
39
|
+
view.setUint16(34, 16, true); // bits per sample
|
|
40
|
+
// data chunk
|
|
41
|
+
writeString(view, 36, 'data');
|
|
42
|
+
view.setUint32(40, pcm.byteLength, true);
|
|
43
|
+
const bytes = new Uint8Array(buffer, 44);
|
|
44
|
+
bytes.set(new Uint8Array(pcm.buffer, pcm.byteOffset, pcm.byteLength));
|
|
45
|
+
return new Blob([buffer], { type: 'audio/wav' });
|
|
46
|
+
}
|
|
47
|
+
function writeString(view, offset, str) {
|
|
48
|
+
for (let i = 0; i < str.length; i++) {
|
|
49
|
+
view.setUint8(offset + i, str.charCodeAt(i));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=pcm-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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AAE,IAAI,CAAC,CAAC;IAEzC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzC,KAAK,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAEtE,OAAO,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,WAAW,CAAC,IAAc,EAAE,MAAc,EAAE,GAAW;IAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resample.d.ts","sourceRoot":"","sources":["../../../stt/audio/resample.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAgB5F"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Linear interpolation resample from one sample rate to another */
|
|
2
|
+
export function resample(input, fromRate, toRate) {
|
|
3
|
+
if (fromRate === toRate)
|
|
4
|
+
return input;
|
|
5
|
+
const ratio = fromRate / toRate;
|
|
6
|
+
const outputLength = Math.round(input.length / ratio);
|
|
7
|
+
const output = new Float32Array(outputLength);
|
|
8
|
+
for (let i = 0; i < outputLength; i++) {
|
|
9
|
+
const srcIndex = i * ratio;
|
|
10
|
+
const srcFloor = Math.floor(srcIndex);
|
|
11
|
+
const srcCeil = Math.min(srcFloor + 1, input.length - 1);
|
|
12
|
+
const frac = srcIndex - srcFloor;
|
|
13
|
+
output[i] = input[srcFloor] * (1 - frac) + input[srcCeil] * frac;
|
|
14
|
+
}
|
|
15
|
+
return output;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=resample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resample.js","sourceRoot":"","sources":["../../../stt/audio/resample.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,UAAU,QAAQ,CAAC,KAAmB,EAAE,QAAgB,EAAE,MAAc;IAC5E,IAAI,QAAQ,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAEtC,MAAM,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAChC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;IAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAAC;QACjC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACnE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Energy-based Voice Activity Detection */
|
|
2
|
+
export interface VADConfig {
|
|
3
|
+
silenceThresholdMs?: number;
|
|
4
|
+
speechThresholdDb?: number;
|
|
5
|
+
frameSizeMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface VADResult {
|
|
8
|
+
isSpeech: boolean;
|
|
9
|
+
speechStarted: boolean;
|
|
10
|
+
speechEnded: boolean;
|
|
11
|
+
energy: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function createVAD(config?: VADConfig): {
|
|
14
|
+
process: (frame: Float32Array) => VADResult;
|
|
15
|
+
reset: () => void;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=vad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vad.d.ts","sourceRoot":"","sources":["../../../stt/audio/vad.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAE5C,MAAM,WAAW,SAAS;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS;qBAQlB,YAAY,KAAG,SAAS;;EAqCjD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Energy-based Voice Activity Detection */
|
|
2
|
+
export function createVAD(config) {
|
|
3
|
+
const silenceMs = config?.silenceThresholdMs ?? 1500;
|
|
4
|
+
const thresholdDb = config?.speechThresholdDb ?? -26;
|
|
5
|
+
const threshold = Math.pow(10, thresholdDb / 20);
|
|
6
|
+
let speaking = false;
|
|
7
|
+
let silenceStart = 0;
|
|
8
|
+
function process(frame) {
|
|
9
|
+
// RMS energy
|
|
10
|
+
let sum = 0;
|
|
11
|
+
for (let i = 0; i < frame.length; i++) {
|
|
12
|
+
sum += frame[i] * frame[i];
|
|
13
|
+
}
|
|
14
|
+
const rms = Math.sqrt(sum / frame.length);
|
|
15
|
+
const isSpeech = rms > threshold;
|
|
16
|
+
let speechStarted = false;
|
|
17
|
+
let speechEnded = false;
|
|
18
|
+
if (isSpeech) {
|
|
19
|
+
if (!speaking) {
|
|
20
|
+
speaking = true;
|
|
21
|
+
speechStarted = true;
|
|
22
|
+
}
|
|
23
|
+
silenceStart = 0;
|
|
24
|
+
}
|
|
25
|
+
else if (speaking) {
|
|
26
|
+
if (silenceStart === 0) {
|
|
27
|
+
silenceStart = Date.now();
|
|
28
|
+
}
|
|
29
|
+
else if (Date.now() - silenceStart > silenceMs) {
|
|
30
|
+
speaking = false;
|
|
31
|
+
speechEnded = true;
|
|
32
|
+
silenceStart = 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { isSpeech, speechStarted, speechEnded, energy: rms };
|
|
36
|
+
}
|
|
37
|
+
function reset() {
|
|
38
|
+
speaking = false;
|
|
39
|
+
silenceStart = 0;
|
|
40
|
+
}
|
|
41
|
+
return { process, reset };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=vad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vad.js","sourceRoot":"","sources":["../../../stt/audio/vad.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAe5C,MAAM,UAAU,SAAS,CAAC,MAAkB;IAC1C,MAAM,SAAS,GAAG,MAAM,EAAE,kBAAkB,IAAI,IAAI,CAAC;IACrD,MAAM,WAAW,GAAG,MAAM,EAAE,iBAAiB,IAAI,CAAC,EAAE,CAAC;IACrD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,GAAG,EAAE,CAAC,CAAC;IAEjD,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,YAAY,GAAG,C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AE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { STTEngineConfig, STTState, STTTranscript, STTError } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* STTEngine orchestrates source -> processing -> provider.
|
|
4
|
+
*
|
|
5
|
+
* For `web-speech` provider: skips audio source (it handles its own mic).
|
|
6
|
+
* For other providers: starts audio source, pipes through optional resample
|
|
7
|
+
* and VAD, buffers audio, and calls provider.transcribe() on speech end.
|
|
8
|
+
*/
|
|
9
|
+
export declare class STTEngine {
|
|
10
|
+
private config;
|
|
11
|
+
private provider;
|
|
12
|
+
private source;
|
|
13
|
+
private sourceUnsub;
|
|
14
|
+
private transcriptListeners;
|
|
15
|
+
private stateListeners;
|
|
16
|
+
private errorListeners;
|
|
17
|
+
private providerUnsubs;
|
|
18
|
+
private vad;
|
|
19
|
+
private buffer;
|
|
20
|
+
private targetSampleRate;
|
|
21
|
+
constructor(config: STTEngineConfig);
|
|
22
|
+
onTranscript(cb: (t: STTTranscript) => void): () => void;
|
|
23
|
+
onStateChange(cb: (s: STTState) => void): () => void;
|
|
24
|
+
onError(cb: (e: STTError) => void): () => void;
|
|
25
|
+
private emitTranscript;
|
|
26
|
+
private emitState;
|
|
27
|
+
private emitError;
|
|
28
|
+
start(): Promise<void>;
|
|
29
|
+
stop(): void;
|
|
30
|
+
abort(): void;
|
|
31
|
+
dispose(): void;
|
|
32
|
+
private resolveSource;
|
|
33
|
+
private processAudio;
|
|
34
|
+
private flushBuffer;
|
|
35
|
+
private subscribeProvider;
|
|
36
|
+
private switchToFallback;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../stt/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAEf,QAAQ,EACR,aAAa,EACb,QAAQ,EAET,MAAM,SAAS,CAAC;AAOjB;;;;;;GAMG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,WAAW,CAA6B;IAEhD,OAAO,CAAC,mBAAmB,CAAyC;IACpE,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,cAAc,CAAoC;IAE1D,OAAO,CAAC,cAAc,CAAyB;IAE/C,OAAO,CAAC,GAAG,CAA6C;IACxD,OAAO,CAAC,MAAM,CAAqD;IACnE,OAAO,CAAC,gBAAgB,CAAS;gBAErB,MAAM,EAAE,eAAe;IAOnC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI;IAQxD,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI;IAQpD,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI;IAQ9C,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;IAMX,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA+D5B,IAAI,IAAI,IAAI;IASZ,KAAK,IAAI,IAAI;IASb,OAAO,IAAI,IAAI;IAef,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,YAAY;YAyBN,WAAW;IAuBzB,OAAO,CAAC,iBAAiB;YAaX,gBAAgB;CAmB/B"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { createProvider } from './registry';
|
|
2
|
+
import { MicrophoneSource } from './sources/microphone';
|
|
3
|
+
import { resample } from './audio/resample';
|
|
4
|
+
import { createVAD } from './audio/vad';
|
|
5
|
+
import { createAudioBuffer } from './audio/buffer';
|
|
6
|
+
/**
|
|
7
|
+
* STTEngine orchestrates source -> processing -> provider.
|
|
8
|
+
*
|
|
9
|
+
* For `web-speech` provider: skips audio source (it handles its own mic).
|
|
10
|
+
* For other providers: starts audio source, pipes through optional resample
|
|
11
|
+
* and VAD, buffers audio, and calls provider.transcribe() on speech end.
|
|
12
|
+
*/
|
|
13
|
+
export class STTEngine {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.provider = null;
|
|
16
|
+
this.source = null;
|
|
17
|
+
this.sourceUnsub = null;
|
|
18
|
+
this.transcriptListeners = [];
|
|
19
|
+
this.stateListeners = [];
|
|
20
|
+
this.errorListeners = [];
|
|
21
|
+
this.providerUnsubs = [];
|
|
22
|
+
this.vad = null;
|
|
23
|
+
this.buffer = null;
|
|
24
|
+
this.config = config;
|
|
25
|
+
this.targetSampleRate = config.sampleRate ?? 16000;
|
|
26
|
+
}
|
|
27
|
+
// ── Event subscriptions ──
|
|
28
|
+
onTranscript(cb) {
|
|
29
|
+
this.transcriptListeners.push(cb);
|
|
30
|
+
return () => {
|
|
31
|
+
const idx = this.transcriptListeners.indexOf(cb);
|
|
32
|
+
if (idx >= 0)
|
|
33
|
+
this.transcriptListeners.splice(idx, 1);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
onStateChange(cb) {
|
|
37
|
+
this.stateListeners.push(cb);
|
|
38
|
+
return () => {
|
|
39
|
+
const idx = this.stateListeners.indexOf(cb);
|
|
40
|
+
if (idx >= 0)
|
|
41
|
+
this.stateListeners.splice(idx, 1);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
onError(cb) {
|
|
45
|
+
this.errorListeners.push(cb);
|
|
46
|
+
return () => {
|
|
47
|
+
const idx = this.errorListeners.indexOf(cb);
|
|
48
|
+
if (idx >= 0)
|
|
49
|
+
this.errorListeners.splice(idx, 1);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
emitTranscript(t) {
|
|
53
|
+
for (const cb of this.transcriptListeners)
|
|
54
|
+
cb(t);
|
|
55
|
+
}
|
|
56
|
+
emitState(s) {
|
|
57
|
+
for (const cb of this.stateListeners)
|
|
58
|
+
cb(s);
|
|
59
|
+
}
|
|
60
|
+
emitError(e) {
|
|
61
|
+
for (const cb of this.errorListeners)
|
|
62
|
+
cb(e);
|
|
63
|
+
}
|
|
64
|
+
// ── Lifecycle ──
|
|
65
|
+
async start() {
|
|
66
|
+
this.emitState('loading');
|
|
67
|
+
try {
|
|
68
|
+
// Create and init provider
|
|
69
|
+
this.provider = await createProvider(this.config.provider);
|
|
70
|
+
this.subscribeProvider(this.provider);
|
|
71
|
+
await this.provider.init({
|
|
72
|
+
language: this.config.language,
|
|
73
|
+
mode: this.config.mode,
|
|
74
|
+
apiKey: this.config.apiKey,
|
|
75
|
+
modelId: this.config.modelId,
|
|
76
|
+
continuous: this.config.continuous,
|
|
77
|
+
vadEnabled: typeof this.config.vad === 'boolean' ? this.config.vad : !!this.config.vad,
|
|
78
|
+
vadSilenceMs: typeof this.config.vad === 'object' ? this.config.vad.silenceMs : undefined,
|
|
79
|
+
sampleRate: this.targetSampleRate,
|
|
80
|
+
});
|
|
81
|
+
// web-speech handles its own microphone
|
|
82
|
+
if (this.config.provider === 'web-speech') {
|
|
83
|
+
this.provider.start();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Set up audio source
|
|
87
|
+
this.source = this.resolveSource();
|
|
88
|
+
await this.source.start();
|
|
89
|
+
// Set up VAD if enabled
|
|
90
|
+
if (this.config.vad) {
|
|
91
|
+
const vadConfig = typeof this.config.vad === 'object' ? {
|
|
92
|
+
silenceThresholdMs: this.config.vad.silenceMs,
|
|
93
|
+
speechThresholdDb: this.config.vad.thresholdDb,
|
|
94
|
+
} : undefined;
|
|
95
|
+
this.vad = createVAD(vadConfig);
|
|
96
|
+
}
|
|
97
|
+
// Set up audio buffer for batch mode
|
|
98
|
+
this.buffer = createAudioBuffer({ sampleRate: this.targetSampleRate });
|
|
99
|
+
// Wire audio pipeline
|
|
100
|
+
this.sourceUnsub = this.source.onAudioData((pcm, sampleRate) => {
|
|
101
|
+
this.processAudio(pcm, sampleRate);
|
|
102
|
+
});
|
|
103
|
+
this.provider.start();
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
const error = {
|
|
107
|
+
code: 'unknown',
|
|
108
|
+
message: err instanceof Error ? err.message : String(err),
|
|
109
|
+
provider: this.config.provider,
|
|
110
|
+
};
|
|
111
|
+
this.emitError(error);
|
|
112
|
+
this.emitState('error');
|
|
113
|
+
// Attempt fallback
|
|
114
|
+
if (this.config.fallback) {
|
|
115
|
+
await this.switchToFallback();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
stop() {
|
|
120
|
+
this.provider?.stop();
|
|
121
|
+
this.sourceUnsub?.();
|
|
122
|
+
this.sourceUnsub = null;
|
|
123
|
+
this.source?.stop();
|
|
124
|
+
this.vad?.reset();
|
|
125
|
+
this.buffer?.clear();
|
|
126
|
+
}
|
|
127
|
+
abort() {
|
|
128
|
+
this.provider?.abort();
|
|
129
|
+
this.sourceUnsub?.();
|
|
130
|
+
this.sourceUnsub = null;
|
|
131
|
+
this.source?.stop();
|
|
132
|
+
this.vad?.reset();
|
|
133
|
+
this.buffer?.clear();
|
|
134
|
+
}
|
|
135
|
+
dispose() {
|
|
136
|
+
this.abort();
|
|
137
|
+
for (const unsub of this.providerUnsubs)
|
|
138
|
+
unsub();
|
|
139
|
+
this.providerUnsubs.length = 0;
|
|
140
|
+
this.provider?.dispose();
|
|
141
|
+
this.provider = null;
|
|
142
|
+
this.source?.dispose();
|
|
143
|
+
this.source = null;
|
|
144
|
+
this.transcriptListeners.length = 0;
|
|
145
|
+
this.stateListeners.length = 0;
|
|
146
|
+
this.errorListeners.length = 0;
|
|
147
|
+
}
|
|
148
|
+
// ── Internal ──
|
|
149
|
+
resolveSource() {
|
|
150
|
+
const src = this.config.source;
|
|
151
|
+
if (!src || src === 'microphone') {
|
|
152
|
+
return new MicrophoneSource();
|
|
153
|
+
}
|
|
154
|
+
if (src === 'glass-bridge') {
|
|
155
|
+
throw new Error('glass-bridge source requires a GlassBridgeSource instance. ' +
|
|
156
|
+
'Pass an AudioSource object directly via config.source.');
|
|
157
|
+
}
|
|
158
|
+
// Custom AudioSource instance
|
|
159
|
+
return src;
|
|
160
|
+
}
|
|
161
|
+
processAudio(pcm, sampleRate) {
|
|
162
|
+
// Resample if needed
|
|
163
|
+
let samples = sampleRate !== this.targetSampleRate
|
|
164
|
+
? resample(pcm, sampleRate, this.targetSampleRate)
|
|
165
|
+
: pcm;
|
|
166
|
+
if (!this.buffer)
|
|
167
|
+
return;
|
|
168
|
+
// If VAD is enabled, check for speech boundaries
|
|
169
|
+
if (this.vad) {
|
|
170
|
+
const result = this.vad.process(samples);
|
|
171
|
+
if (result.isSpeech || result.speechEnded) {
|
|
172
|
+
this.buffer.append(samples);
|
|
173
|
+
}
|
|
174
|
+
if (result.speechEnded) {
|
|
175
|
+
this.flushBuffer();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
// No VAD: accumulate everything, provider handles streaming
|
|
180
|
+
this.buffer.append(samples);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async flushBuffer() {
|
|
184
|
+
if (!this.buffer || !this.provider)
|
|
185
|
+
return;
|
|
186
|
+
const audio = this.buffer.getAll();
|
|
187
|
+
this.buffer.clear();
|
|
188
|
+
if (audio.length === 0)
|
|
189
|
+
return;
|
|
190
|
+
// If provider supports batch transcription
|
|
191
|
+
if (this.provider.transcribe) {
|
|
192
|
+
try {
|
|
193
|
+
const transcript = await this.provider.transcribe(audio, this.targetSampleRate);
|
|
194
|
+
this.emitTranscript(transcript);
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
this.emitError({
|
|
198
|
+
code: 'unknown',
|
|
199
|
+
message: err instanceof Error ? err.message : String(err),
|
|
200
|
+
provider: this.config.provider,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
subscribeProvider(provider) {
|
|
206
|
+
this.providerUnsubs.push(provider.onTranscript((t) => this.emitTranscript(t)), provider.onStateChange((s) => this.emitState(s)), provider.onError((e) => {
|
|
207
|
+
this.emitError(e);
|
|
208
|
+
if (this.config.fallback) {
|
|
209
|
+
this.switchToFallback();
|
|
210
|
+
}
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
async switchToFallback() {
|
|
214
|
+
if (!this.config.fallback)
|
|
215
|
+
return;
|
|
216
|
+
// Clean up current provider
|
|
217
|
+
for (const unsub of this.providerUnsubs)
|
|
218
|
+
unsub();
|
|
219
|
+
this.providerUnsubs.length = 0;
|
|
220
|
+
this.provider?.dispose();
|
|
221
|
+
this.provider = null;
|
|
222
|
+
// Switch to fallback
|
|
223
|
+
const fallbackType = this.config.fallback;
|
|
224
|
+
this.config = { ...this.config, provider: fallbackType, fallback: undefined };
|
|
225
|
+
try {
|
|
226
|
+
await this.start();
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
// Fallback also failed — nothing more to do
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../stt/engine.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,OAAO,SAAS;IAgBpB,YAAY,MAAuB;QAd3B,aAAQ,GAAuB,IAAI,CAAC;QACpC,WAAM,GAAuB,IAAI,CAAC;QAClC,gBAAW,GAAwB,IAAI,CAAC;QAEx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|
|
4
|
+
/** Short code → BCP 47 (best guess) */
|
|
5
|
+
export declare function toWebSpeechLang(lang: string): string;
|
|
6
|
+
export interface SupportedLanguage {
|
|
7
|
+
code: string;
|
|
8
|
+
name: string;
|
|
9
|
+
whisper: boolean;
|
|
10
|
+
webSpeech: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const SUPPORTED_LANGUAGES: SupportedLanguage[];
|
|
13
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../stt/i18n.ts"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,iCAAiC;AACjC,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,uCAAuC;AACvC,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,EAalD,CAAC"}
|
package/dist/stt/i18n.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Language mapping utilities for STT providers */
|
|
2
|
+
/** BCP 47 → Whisper ISO 639-1 */
|
|
3
|
+
export function toWhisperLang(bcp47) {
|
|
4
|
+
return bcp47.split('-')[0].toLowerCase();
|
|
5
|
+
}
|
|
6
|
+
/** Short code → BCP 47 (best guess) */
|
|
7
|
+
export function toWebSpeechLang(lang) {
|
|
8
|
+
const map = {
|
|
9
|
+
en: 'en-US', it: 'it-IT', es: 'es-ES', fr: 'fr-FR',
|
|
10
|
+
de: 'de-DE', pt: 'pt-BR', zh: 'zh-CN', ja: 'ja-JP',
|
|
11
|
+
ko: 'ko-KR', ru: 'ru-RU', ar: 'ar-SA', hi: 'hi-IN',
|
|
12
|
+
};
|
|
13
|
+
if (lang.includes('-'))
|
|
14
|
+
return lang;
|
|
15
|
+
return map[lang.toLowerCase()] ?? `${lang}-${lang.toUpperCase()}`;
|
|
16
|
+
}
|
|
17
|
+
export const SUPPORTED_LANGUAGES = [
|
|
18
|
+
{ code: 'en-US', name: 'English', whisper: true, webSpeech: true },
|
|
19
|
+
{ code: 'it-IT', name: 'Italian', whisper: true, webSpeech: true },
|
|
20
|
+
{ code: 'es-ES', name: 'Spanish', whisper: true, webSpeech: true },
|
|
21
|
+
{ code: 'fr-FR', name: 'French', whisper: true, webSpeech: true },
|
|
22
|
+
{ code: 'de-DE', name: 'German', whisper: true, webSpeech: true },
|
|
23
|
+
{ code: 'pt-BR', name: 'Portuguese', whisper: true, webSpeech: true },
|
|
24
|
+
{ code: 'zh-CN', name: 'Chinese', whisper: true, webSpeech: true },
|
|
25
|
+
{ code: 'ja-JP', name: 'Japanese', whisper: true, webSpeech: true },
|
|
26
|
+
{ code: 'ko-KR', name: 'Korean', whisper: true, webSpeech: true },
|
|
27
|
+
{ code: 'ru-RU', name: 'Russian', whisper: true, webSpeech: true },
|
|
28
|
+
{ code: 'ar-SA', name: 'Arabic', whisper: true, webSpeech: true },
|
|
29
|
+
{ code: 'hi-IN', name: 'Hindi', whisper: true, webSpeech: true },
|
|
30
|
+
];
|
|
31
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../stt/i18n.ts"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,iCAAiC;AACjC,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC3C,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,GAAG,GAA2B;QAClC,EAAE,E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AAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IAClE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IACnE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IACjE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IAClE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IACjE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;CACjE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export { STTEngine } from './engine';
|
|
3
|
+
export { createProvider } from './registry';
|
|
4
|
+
export * from './i18n';
|
|
5
|
+
export { MicrophoneSource } from './sources/microphone';
|
|
6
|
+
export { GlassBridgeSource } from './sources/glass-bridge';
|
|
7
|
+
export * from './audio/pcm-utils';
|
|
8
|
+
export * from './audio/resample';
|
|
9
|
+
export * from './audio/vad';
|
|
10
|
+
export { createAudioBuffer } from './audio/buffer';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../stt/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export { STTEngine } from './engine';
|
|
3
|
+
export { createProvider } from './registry';
|
|
4
|
+
export * from './i18n';
|
|
5
|
+
export { MicrophoneSource } from './sources/microphone';
|
|
6
|
+
export { GlassBridgeSource } from './sources/glass-bridge';
|
|
7
|
+
export * from './audio/pcm-utils';
|
|
8
|
+
export * from './audio/resample';
|
|
9
|
+
export * from './audio/vad';
|
|
10
|
+
export { createAudioBuffer } from './audio/buffer';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../stt/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { STTProvider, STTProviderConfig, STTMode, STTState, STTTranscript, STTError } from '../types';
|
|
2
|
+
export declare class DeepgramProvider implements STTProvider {
|
|
3
|
+
readonly type: "deepgram";
|
|
4
|
+
readonly supportedModes: STTMode[];
|
|
5
|
+
private _state;
|
|
6
|
+
private apiKey;
|
|
7
|
+
private language;
|
|
8
|
+
private modelId;
|
|
9
|
+
private ws;
|
|
10
|
+
private transcriptCbs;
|
|
11
|
+
private stateCbs;
|
|
12
|
+
private errorCbs;
|
|
13
|
+
get state(): STTState;
|
|
14
|
+
init(config: STTProviderConfig): Promise<void>;
|
|
15
|
+
start(): void;
|
|
16
|
+
/** Send raw audio data (PCM Int16 or Float32 as ArrayBuffer) to the Deepgram stream. */
|
|
17
|
+
sendAudio(data: ArrayBuffer | Int16Array | Float32Array): void;
|
|
18
|
+
stop(): void;
|
|
19
|
+
abort(): void;
|
|
20
|
+
dispose(): void;
|
|
21
|
+
onTranscript(cb: (t: STTTranscript) => void): () => void;
|
|
22
|
+
onStateChange(cb: (s: STTState) => void): () => void;
|
|
23
|
+
onError(cb: (e: STTError) => void): () => void;
|
|
24
|
+
private closeSocket;
|
|
25
|
+
private setState;
|
|
26
|
+
private emitTranscript;
|
|
27
|
+
private emitError;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=deepgram.d.ts.map
|