ug-js-sdk 3.0.59 → 3.0.60
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.
|
@@ -25,7 +25,7 @@ export declare const VadManagerEvents: {
|
|
|
25
25
|
* 300, // silenceTimeoutMs - time after speech ends before emitting Silence
|
|
26
26
|
* 0.5, // positiveSpeechThreshold - probability threshold to detect speech
|
|
27
27
|
* 0.35, // negativeSpeechThreshold - probability threshold to end speech
|
|
28
|
-
*
|
|
28
|
+
* 3 // minSpeechFrames - minimum speech frames to avoid misfires
|
|
29
29
|
* )
|
|
30
30
|
*
|
|
31
31
|
* vad.on(VadManagerEvents.VoiceActivity, (event) => {
|
|
@@ -53,7 +53,7 @@ export declare class VADManager extends EventEmitter implements IVADManager {
|
|
|
53
53
|
private silenceTimeoutMs;
|
|
54
54
|
private positiveSpeechThreshold;
|
|
55
55
|
private negativeSpeechThreshold;
|
|
56
|
-
private
|
|
56
|
+
private minSpeechFrames;
|
|
57
57
|
private isDisposed;
|
|
58
58
|
private currentStream;
|
|
59
59
|
/**
|
|
@@ -62,9 +62,9 @@ export declare class VADManager extends EventEmitter implements IVADManager {
|
|
|
62
62
|
* @param silenceTimeoutMs - Time in ms after speech ends before emitting Silence event (default: 300)
|
|
63
63
|
* @param positiveSpeechThreshold - Probability threshold to start speech detection, 0-1 (default: 0.5)
|
|
64
64
|
* @param negativeSpeechThreshold - Probability threshold to end speech detection, 0-1 (default: 0.35)
|
|
65
|
-
* @param
|
|
65
|
+
* @param minSpeechFrames - Minimum number of speech frames to avoid misfires (default: 3)
|
|
66
66
|
*/
|
|
67
|
-
constructor(silenceTimeoutMs?: number, positiveSpeechThreshold?: number, negativeSpeechThreshold?: number,
|
|
67
|
+
constructor(silenceTimeoutMs?: number, positiveSpeechThreshold?: number, negativeSpeechThreshold?: number, minSpeechFrames?: number);
|
|
68
68
|
/**
|
|
69
69
|
* Initialize the VAD model. Accepts a MediaStream to use for voice activity detection.
|
|
70
70
|
*/
|
|
@@ -26,7 +26,7 @@ export const VadManagerEvents = {
|
|
|
26
26
|
* 300, // silenceTimeoutMs - time after speech ends before emitting Silence
|
|
27
27
|
* 0.5, // positiveSpeechThreshold - probability threshold to detect speech
|
|
28
28
|
* 0.35, // negativeSpeechThreshold - probability threshold to end speech
|
|
29
|
-
*
|
|
29
|
+
* 3 // minSpeechFrames - minimum speech frames to avoid misfires
|
|
30
30
|
* )
|
|
31
31
|
*
|
|
32
32
|
* vad.on(VadManagerEvents.VoiceActivity, (event) => {
|
|
@@ -54,7 +54,7 @@ export class VADManager extends EventEmitter {
|
|
|
54
54
|
silenceTimeoutMs;
|
|
55
55
|
positiveSpeechThreshold;
|
|
56
56
|
negativeSpeechThreshold;
|
|
57
|
-
|
|
57
|
+
minSpeechFrames;
|
|
58
58
|
isDisposed = false;
|
|
59
59
|
currentStream = null;
|
|
60
60
|
/**
|
|
@@ -63,15 +63,15 @@ export class VADManager extends EventEmitter {
|
|
|
63
63
|
* @param silenceTimeoutMs - Time in ms after speech ends before emitting Silence event (default: 300)
|
|
64
64
|
* @param positiveSpeechThreshold - Probability threshold to start speech detection, 0-1 (default: 0.5)
|
|
65
65
|
* @param negativeSpeechThreshold - Probability threshold to end speech detection, 0-1 (default: 0.35)
|
|
66
|
-
* @param
|
|
66
|
+
* @param minSpeechFrames - Minimum number of speech frames to avoid misfires (default: 3)
|
|
67
67
|
*/
|
|
68
|
-
constructor(silenceTimeoutMs = 300, positiveSpeechThreshold = 0.5, negativeSpeechThreshold = 0.35,
|
|
68
|
+
constructor(silenceTimeoutMs = 300, positiveSpeechThreshold = 0.5, negativeSpeechThreshold = 0.35, minSpeechFrames = 3) {
|
|
69
69
|
const logger = new DefaultLogger({ category: '🎤 VADManager', style: StylePurple });
|
|
70
70
|
super(logger);
|
|
71
71
|
this.silenceTimeoutMs = silenceTimeoutMs;
|
|
72
72
|
this.positiveSpeechThreshold = positiveSpeechThreshold;
|
|
73
73
|
this.negativeSpeechThreshold = negativeSpeechThreshold;
|
|
74
|
-
this.
|
|
74
|
+
this.minSpeechFrames = minSpeechFrames;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Initialize the VAD model. Accepts a MediaStream to use for voice activity detection.
|
|
@@ -81,32 +81,13 @@ export class VADManager extends EventEmitter {
|
|
|
81
81
|
return;
|
|
82
82
|
this.currentStream = stream;
|
|
83
83
|
this.logger.debug('You may need to close the browser console for this to initialize');
|
|
84
|
-
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
85
84
|
const vadModel = await MicVAD.new({
|
|
86
|
-
|
|
87
|
-
// (WebKit bug #255103). Single-threaded is fine for the small Silero VAD model.
|
|
88
|
-
...(isSafari && {
|
|
89
|
-
ortConfig: (ort) => {
|
|
90
|
-
ort.env.wasm.numThreads = 1;
|
|
91
|
-
},
|
|
92
|
-
}),
|
|
93
|
-
// New API uses callbacks for stream management
|
|
94
|
-
getStream: async () => {
|
|
95
|
-
if (!this.currentStream) {
|
|
96
|
-
throw new Error('Stream is no longer available - VADManager may have been disposed');
|
|
97
|
-
}
|
|
98
|
-
return this.currentStream;
|
|
99
|
-
},
|
|
100
|
-
pauseStream: async () => {
|
|
101
|
-
// We don't stop the stream since it's managed externally
|
|
102
|
-
},
|
|
103
|
-
resumeStream: async (existingStream) => existingStream,
|
|
104
|
-
startOnLoad: false,
|
|
85
|
+
stream,
|
|
105
86
|
baseAssetPath: '/static/binaries/', // Serve those locally
|
|
106
87
|
onnxWASMBasePath: '/static/binaries/', // Serve those locally
|
|
107
88
|
positiveSpeechThreshold: this.positiveSpeechThreshold,
|
|
108
89
|
negativeSpeechThreshold: this.negativeSpeechThreshold,
|
|
109
|
-
|
|
90
|
+
minSpeechFrames: this.minSpeechFrames,
|
|
110
91
|
onSpeechStart: async () => {
|
|
111
92
|
if (this.isDisposed)
|
|
112
93
|
return;
|
|
@@ -153,7 +134,7 @@ export class VADManager extends EventEmitter {
|
|
|
153
134
|
return;
|
|
154
135
|
}
|
|
155
136
|
this.vadModel = vadModel;
|
|
156
|
-
this.logger.debug(`VAD Manager initialized (MicVAD) with silenceTimeoutMs=${this.silenceTimeoutMs}, positiveSpeechThreshold=${this.positiveSpeechThreshold}, negativeSpeechThreshold=${this.negativeSpeechThreshold},
|
|
137
|
+
this.logger.debug(`VAD Manager initialized (MicVAD) with silenceTimeoutMs=${this.silenceTimeoutMs}, positiveSpeechThreshold=${this.positiveSpeechThreshold}, negativeSpeechThreshold=${this.negativeSpeechThreshold}, minSpeechFrames=${this.minSpeechFrames}`);
|
|
157
138
|
}
|
|
158
139
|
/**
|
|
159
140
|
* Starts voice activity detection analysis.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VADManager.js","sourceRoot":"","sources":["../../../src/ug-core/user-input-manager/VADManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAI3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,mEAAmE;IACnE,aAAa,EAAE,eAAe;IAC9B,0EAA0E;IAC1E,OAAO,EAAE,SAAS;CACV,CAAA;AAEV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,OAAO,UAAW,SAAQ,YAAY;IAClC,QAAQ,GAAQ,IAAI,CAAA;IACpB,YAAY,GAAkB,IAAI,CAAA;IAClC,gBAAgB,CAAQ;IACxB,uBAAuB,CAAQ;IAC/B,uBAAuB,CAAQ;IAC/B,
|
|
1
|
+
{"version":3,"file":"VADManager.js","sourceRoot":"","sources":["../../../src/ug-core/user-input-manager/VADManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,WA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