@vapi-ai/web 1.0.243 → 1.0.245
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 +12 -15
- package/package.json +1 -1
- package/vapi.ts +11 -15
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,23 +171,22 @@ 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
|
-
|
|
177
|
-
this.averageSpeechLevel * 0.95 + speechLevel * 0.05;
|
|
178
|
-
this.speechLevel = this.speechLevel * 0.9 + speechLevel * 0.1;
|
|
174
|
+
console.log(speechLevel);
|
|
179
175
|
this.emit("volume-level", Math.min(1, speechLevel / 0.15));
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const hasStoppedSpeaking = this.speechLevel < this.averageSpeechLevel * 0.5;
|
|
183
|
-
if (!this.isSpeaking && hasStartedSpeaking) {
|
|
184
|
-
this.isSpeaking = true;
|
|
185
|
-
this.emit("speech-start");
|
|
176
|
+
const isSpeaking = speechLevel > 0.01;
|
|
177
|
+
if (!isSpeaking)
|
|
186
178
|
return;
|
|
179
|
+
if (this.speakingTimeout) {
|
|
180
|
+
clearTimeout(this.speakingTimeout);
|
|
181
|
+
this.speakingTimeout = null;
|
|
187
182
|
}
|
|
188
|
-
|
|
189
|
-
this.
|
|
190
|
-
this.emit("speech-end");
|
|
191
|
-
return;
|
|
183
|
+
else {
|
|
184
|
+
this.emit("speech-start");
|
|
192
185
|
}
|
|
186
|
+
this.speakingTimeout = setTimeout(() => {
|
|
187
|
+
this.emit("speech-end");
|
|
188
|
+
this.speakingTimeout = null;
|
|
189
|
+
}, 1000);
|
|
193
190
|
}
|
|
194
191
|
stop() {
|
|
195
192
|
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,28 +211,26 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
213
211
|
(a, b) => a + b,
|
|
214
212
|
0
|
|
215
213
|
);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
this.speechLevel = this.speechLevel * 0.9 + speechLevel * 0.1;
|
|
214
|
+
|
|
215
|
+
console.log(speechLevel);
|
|
219
216
|
|
|
220
217
|
this.emit("volume-level", Math.min(1, speechLevel / 0.15));
|
|
221
218
|
|
|
222
|
-
|
|
219
|
+
const isSpeaking = speechLevel > 0.01;
|
|
223
220
|
|
|
224
|
-
|
|
225
|
-
const hasStoppedSpeaking = this.speechLevel < this.averageSpeechLevel * 0.5;
|
|
221
|
+
if (!isSpeaking) return;
|
|
226
222
|
|
|
227
|
-
if (
|
|
228
|
-
this.
|
|
223
|
+
if (this.speakingTimeout) {
|
|
224
|
+
clearTimeout(this.speakingTimeout);
|
|
225
|
+
this.speakingTimeout = null;
|
|
226
|
+
} else {
|
|
229
227
|
this.emit("speech-start");
|
|
230
|
-
return;
|
|
231
228
|
}
|
|
232
229
|
|
|
233
|
-
|
|
234
|
-
this.isSpeaking = false;
|
|
230
|
+
this.speakingTimeout = setTimeout(() => {
|
|
235
231
|
this.emit("speech-end");
|
|
236
|
-
|
|
237
|
-
}
|
|
232
|
+
this.speakingTimeout = null;
|
|
233
|
+
}, 1000);
|
|
238
234
|
}
|
|
239
235
|
|
|
240
236
|
stop(): void {
|