@vapi-ai/web 1.0.244 → 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 -14
- package/package.json +1 -1
- package/vapi.ts +12 -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,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.92 + speechLevel * 0.08;
|
|
174
|
+
console.log(speechLevel);
|
|
179
175
|
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");
|
|
176
|
+
const isSpeaking = speechLevel > 0.01;
|
|
177
|
+
if (!isSpeaking)
|
|
185
178
|
return;
|
|
179
|
+
if (this.speakingTimeout) {
|
|
180
|
+
clearTimeout(this.speakingTimeout);
|
|
181
|
+
this.speakingTimeout = null;
|
|
186
182
|
}
|
|
187
|
-
|
|
188
|
-
this.
|
|
189
|
-
this.emit("speech-end");
|
|
190
|
-
return;
|
|
183
|
+
else {
|
|
184
|
+
this.emit("speech-start");
|
|
191
185
|
}
|
|
186
|
+
this.speakingTimeout = setTimeout(() => {
|
|
187
|
+
this.emit("speech-end");
|
|
188
|
+
this.speakingTimeout = null;
|
|
189
|
+
}, 1000);
|
|
192
190
|
}
|
|
193
191
|
stop() {
|
|
194
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,26 +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.92 + speechLevel * 0.08;
|
|
214
|
+
|
|
215
|
+
console.log(speechLevel);
|
|
219
216
|
|
|
220
217
|
this.emit("volume-level", Math.min(1, speechLevel / 0.15));
|
|
221
218
|
|
|
222
|
-
const
|
|
223
|
-
|
|
219
|
+
const isSpeaking = speechLevel > 0.01;
|
|
220
|
+
|
|
221
|
+
if (!isSpeaking) return;
|
|
224
222
|
|
|
225
|
-
if (
|
|
226
|
-
this.
|
|
223
|
+
if (this.speakingTimeout) {
|
|
224
|
+
clearTimeout(this.speakingTimeout);
|
|
225
|
+
this.speakingTimeout = null;
|
|
226
|
+
} else {
|
|
227
227
|
this.emit("speech-start");
|
|
228
|
-
return;
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
|
|
232
|
-
this.isSpeaking = false;
|
|
230
|
+
this.speakingTimeout = setTimeout(() => {
|
|
233
231
|
this.emit("speech-end");
|
|
234
|
-
|
|
235
|
-
}
|
|
232
|
+
this.speakingTimeout = null;
|
|
233
|
+
}, 1000);
|
|
236
234
|
}
|
|
237
235
|
|
|
238
236
|
stop(): void {
|