@vapi-ai/web 1.0.237 → 1.0.238
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 +1 -0
- package/dist/vapi.js +4 -1
- package/package.json +1 -1
- package/vapi.ts +5 -1
package/dist/vapi.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
22
22
|
private started;
|
|
23
23
|
private call;
|
|
24
24
|
private speakingTimeout;
|
|
25
|
+
private averageSpeechLevel;
|
|
25
26
|
constructor(apiToken: string, apiBaseUrl?: string);
|
|
26
27
|
private cleanup;
|
|
27
28
|
start(assistant: CreateAssistantDTO | string): Promise<Call | null>;
|
package/dist/vapi.js
CHANGED
|
@@ -75,6 +75,7 @@ class Vapi extends VapiEventEmitter {
|
|
|
75
75
|
this.started = false;
|
|
76
76
|
this.call = null;
|
|
77
77
|
this.speakingTimeout = null;
|
|
78
|
+
this.averageSpeechLevel = 0;
|
|
78
79
|
client_1.client.baseUrl = apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : "https://api.vapi.ai";
|
|
79
80
|
client_1.client.setSecurityData(apiToken);
|
|
80
81
|
}
|
|
@@ -170,8 +171,10 @@ class Vapi extends VapiEventEmitter {
|
|
|
170
171
|
}
|
|
171
172
|
handleRemoteParticipantsAudioLevel(e) {
|
|
172
173
|
const speechLevel = Object.values(e.participantsAudioLevel).reduce((a, b) => a + b, 0);
|
|
174
|
+
this.averageSpeechLevel =
|
|
175
|
+
this.averageSpeechLevel * 0.95 + speechLevel * 0.05;
|
|
173
176
|
this.emit("volume-level", Math.min(1, speechLevel / 0.15));
|
|
174
|
-
const isSpeaking = speechLevel >
|
|
177
|
+
const isSpeaking = speechLevel > this.averageSpeechLevel * 1.5;
|
|
175
178
|
if (!isSpeaking)
|
|
176
179
|
return;
|
|
177
180
|
if (this.speakingTimeout) {
|
package/package.json
CHANGED
package/vapi.ts
CHANGED
|
@@ -99,6 +99,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
99
99
|
private started: boolean = false;
|
|
100
100
|
private call: DailyCall | null = null;
|
|
101
101
|
private speakingTimeout: NodeJS.Timeout | null = null;
|
|
102
|
+
private averageSpeechLevel: number = 0;
|
|
102
103
|
|
|
103
104
|
constructor(apiToken: string, apiBaseUrl?: string) {
|
|
104
105
|
super();
|
|
@@ -210,9 +211,12 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
210
211
|
(a, b) => a + b,
|
|
211
212
|
0
|
|
212
213
|
);
|
|
214
|
+
this.averageSpeechLevel =
|
|
215
|
+
this.averageSpeechLevel * 0.95 + speechLevel * 0.05;
|
|
216
|
+
|
|
213
217
|
this.emit("volume-level", Math.min(1, speechLevel / 0.15));
|
|
214
218
|
|
|
215
|
-
const isSpeaking = speechLevel >
|
|
219
|
+
const isSpeaking = speechLevel > this.averageSpeechLevel * 1.5;
|
|
216
220
|
if (!isSpeaking) return;
|
|
217
221
|
|
|
218
222
|
if (this.speakingTimeout) {
|