@vapi-ai/web 1.0.215 → 1.0.216

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/README.md CHANGED
@@ -68,6 +68,10 @@ vapi.on('call-end', () => {
68
68
  console.log('Call has stopped');
69
69
  });
70
70
 
71
+ vapi.on('volume-level', (volume) => {
72
+ console.log(`Assistant volume level: ${volume}`);
73
+ });
74
+
71
75
  vapi.on('error', (e) => {
72
76
  console.error(e)
73
77
  });
package/dist/vapi.js CHANGED
@@ -109,7 +109,7 @@ class Vapi extends events_1.default {
109
109
  url: webCallUrl,
110
110
  subscribeToTracksAutomatically: false,
111
111
  });
112
- this.call.startRemoteParticipantsAudioLevelObserver();
112
+ this.call.startRemoteParticipantsAudioLevelObserver(100);
113
113
  this.call.on("remote-participants-audio-level", (e) => this.handleRemoteParticipantsAudioLevel(e));
114
114
  this.call.updateInputSettings({
115
115
  audio: {
@@ -126,7 +126,9 @@ class Vapi extends events_1.default {
126
126
  });
127
127
  }
128
128
  handleRemoteParticipantsAudioLevel(e) {
129
- const isSpeaking = Object.values(e.participantsAudioLevel).some((v) => v > 0.01);
129
+ const speechLevel = Object.values(e.participantsAudioLevel).reduce((a, b) => a + b, 0);
130
+ this.emit("volume-level", speechLevel);
131
+ const isSpeaking = speechLevel > 0.1;
130
132
  if (!isSpeaking)
131
133
  return;
132
134
  if (this.speakingTimeout) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.215",
3
+ "version": "1.0.216",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/vapi.ts CHANGED
@@ -108,7 +108,7 @@ export default class Vapi extends EventEmitter {
108
108
  subscribeToTracksAutomatically: false,
109
109
  });
110
110
 
111
- this.call.startRemoteParticipantsAudioLevelObserver();
111
+ this.call.startRemoteParticipantsAudioLevelObserver(100);
112
112
  this.call.on("remote-participants-audio-level", (e) =>
113
113
  this.handleRemoteParticipantsAudioLevel(e)
114
114
  );
@@ -131,9 +131,13 @@ export default class Vapi extends EventEmitter {
131
131
  private handleRemoteParticipantsAudioLevel(
132
132
  e: DailyEventObjectRemoteParticipantsAudioLevel
133
133
  ) {
134
- const isSpeaking = Object.values(e.participantsAudioLevel).some(
135
- (v) => v > 0.01
134
+ const speechLevel = Object.values(e.participantsAudioLevel).reduce(
135
+ (a, b) => a + b,
136
+ 0
136
137
  );
138
+ this.emit("volume-level", speechLevel);
139
+
140
+ const isSpeaking = speechLevel > 0.1;
137
141
  if (!isSpeaking) return;
138
142
 
139
143
  if (this.speakingTimeout) {