@vapi-ai/web 1.0.244 → 1.0.246
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/vapi.d.ts +0 -2
- package/dist/vapi.js +11 -14
- package/package.json +1 -1
- package/vapi.ts +10 -14
package/dist/vapi.d.ts
CHANGED
|
@@ -23,8 +23,6 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
23
23
|
private call;
|
|
24
24
|
private speakingTimeout;
|
|
25
25
|
private averageSpeechLevel;
|
|
26
|
-
private speechLevel;
|
|
27
|
-
private isSpeaking;
|
|
28
26
|
constructor(apiToken: string, apiBaseUrl?: string);
|
|
29
27
|
private cleanup;
|
|
30
28
|
start(assistant: CreateAssistantDTO | string): Promise<Call | null>;
|
package/dist/vapi.js
CHANGED
|
@@ -76,8 +76,6 @@ class Vapi extends VapiEventEmitter {
|
|
|
76
76
|
this.call = null;
|
|
77
77
|
this.speakingTimeout = null;
|
|
78
78
|
this.averageSpeechLevel = 0;
|
|
79
|
-
this.speechLevel = 0;
|
|
80
|
-
this.isSpeaking = false;
|
|
81
79
|
client_1.client.baseUrl = apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : "https://api.vapi.ai";
|
|
82
80
|
client_1.client.setSecurityData(apiToken);
|
|
83
81
|
}
|
|
@@ -173,22 +171,21 @@ class Vapi extends VapiEventEmitter {
|
|
|
173
171
|
}
|
|
174
172
|
handleRemoteParticipantsAudioLevel(e) {
|
|
175
173
|
const speechLevel = Object.values(e.participantsAudioLevel).reduce((a, b) => a + b, 0);
|
|
176
|
-
this.averageSpeechLevel =
|
|
177
|
-
this.averageSpeechLevel * 0.95 + speechLevel * 0.05;
|
|
178
|
-
this.speechLevel = this.speechLevel * 0.92 + speechLevel * 0.08;
|
|
179
174
|
this.emit("volume-level", Math.min(1, speechLevel / 0.15));
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
if (!this.isSpeaking && hasStartedSpeaking) {
|
|
183
|
-
this.isSpeaking = true;
|
|
184
|
-
this.emit("speech-start");
|
|
175
|
+
const isSpeaking = speechLevel > 0.01;
|
|
176
|
+
if (!isSpeaking)
|
|
185
177
|
return;
|
|
178
|
+
if (this.speakingTimeout) {
|
|
179
|
+
clearTimeout(this.speakingTimeout);
|
|
180
|
+
this.speakingTimeout = null;
|
|
186
181
|
}
|
|
187
|
-
|
|
188
|
-
this.
|
|
189
|
-
this.emit("speech-end");
|
|
190
|
-
return;
|
|
182
|
+
else {
|
|
183
|
+
this.emit("speech-start");
|
|
191
184
|
}
|
|
185
|
+
this.speakingTimeout = setTimeout(() => {
|
|
186
|
+
this.emit("speech-end");
|
|
187
|
+
this.speakingTimeout = null;
|
|
188
|
+
}, 1000);
|
|
192
189
|
}
|
|
193
190
|
stop() {
|
|
194
191
|
var _a;
|
package/package.json
CHANGED
package/vapi.ts
CHANGED
|
@@ -100,8 +100,6 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
100
100
|
private call: DailyCall | null = null;
|
|
101
101
|
private speakingTimeout: NodeJS.Timeout | null = null;
|
|
102
102
|
private averageSpeechLevel: number = 0;
|
|
103
|
-
private speechLevel: number = 0;
|
|
104
|
-
private isSpeaking: boolean = false;
|
|
105
103
|
|
|
106
104
|
constructor(apiToken: string, apiBaseUrl?: string) {
|
|
107
105
|
super();
|
|
@@ -213,26 +211,24 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
213
211
|
(a, b) => a + b,
|
|
214
212
|
0
|
|
215
213
|
);
|
|
216
|
-
this.averageSpeechLevel =
|
|
217
|
-
this.averageSpeechLevel * 0.95 + speechLevel * 0.05;
|
|
218
|
-
this.speechLevel = this.speechLevel * 0.92 + speechLevel * 0.08;
|
|
219
214
|
|
|
220
215
|
this.emit("volume-level", Math.min(1, speechLevel / 0.15));
|
|
221
216
|
|
|
222
|
-
const
|
|
223
|
-
const hasStoppedSpeaking = this.speechLevel < this.averageSpeechLevel * 0.5;
|
|
217
|
+
const isSpeaking = speechLevel > 0.01;
|
|
224
218
|
|
|
225
|
-
if (!
|
|
226
|
-
|
|
219
|
+
if (!isSpeaking) return;
|
|
220
|
+
|
|
221
|
+
if (this.speakingTimeout) {
|
|
222
|
+
clearTimeout(this.speakingTimeout);
|
|
223
|
+
this.speakingTimeout = null;
|
|
224
|
+
} else {
|
|
227
225
|
this.emit("speech-start");
|
|
228
|
-
return;
|
|
229
226
|
}
|
|
230
227
|
|
|
231
|
-
|
|
232
|
-
this.isSpeaking = false;
|
|
228
|
+
this.speakingTimeout = setTimeout(() => {
|
|
233
229
|
this.emit("speech-end");
|
|
234
|
-
|
|
235
|
-
}
|
|
230
|
+
this.speakingTimeout = null;
|
|
231
|
+
}, 1000);
|
|
236
232
|
}
|
|
237
233
|
|
|
238
234
|
stop(): void {
|