@vapi-ai/web 1.0.155 → 1.0.157

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 CHANGED
@@ -6,6 +6,6 @@ export default class Vapi extends EventEmitter {
6
6
  private call;
7
7
  constructor(apiToken: string, apiBaseUrl?: string);
8
8
  start(assistant: CreateAssistantDTO | string): void;
9
- private handleParticipantsAudioLevel;
9
+ private handleSpeakerChange;
10
10
  stop(): void;
11
11
  }
package/dist/vapi.js CHANGED
@@ -33,16 +33,22 @@ class Vapi extends events_1.default {
33
33
  });
34
34
  (_a = this.call.iframe()) === null || _a === void 0 ? void 0 : _a.style.setProperty("display", "none");
35
35
  this.call.join({ url });
36
- this.call.on("remote-participants-audio-level", (participantsAudioLevel) => this.handleParticipantsAudioLevel(participantsAudioLevel));
37
- this.call.startRemoteParticipantsAudioLevelObserver(500);
36
+ this.call.on("active-speaker-change", (e) => this.handleSpeakerChange(e));
38
37
  })
39
38
  .catch((error) => {
40
39
  console.error(error);
41
40
  });
42
41
  }
43
- handleParticipantsAudioLevel(participantsAudioLevel) {
44
- const level = Object.values(participantsAudioLevel).reduce((a, b) => a + b, 0);
45
- console.log(level);
42
+ handleSpeakerChange(speaker) {
43
+ var _a, _b, _c, _d;
44
+ console.log(speaker);
45
+ console.log((_a = this.call) === null || _a === void 0 ? void 0 : _a.participants());
46
+ if ((speaker === null || speaker === void 0 ? void 0 : speaker.userId) === ((_d = (_c = (_b = this.call) === null || _b === void 0 ? void 0 : _b.participants()) === null || _c === void 0 ? void 0 : _c.local) === null || _d === void 0 ? void 0 : _d.user_id)) {
47
+ this.emit("speech-end");
48
+ }
49
+ else {
50
+ this.emit("speech-start");
51
+ }
46
52
  }
47
53
  stop() {
48
54
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.155",
3
+ "version": "1.0.157",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/vapi.ts CHANGED
@@ -36,24 +36,23 @@ export default class Vapi extends EventEmitter {
36
36
  this.call.iframe()?.style.setProperty("display", "none");
37
37
  this.call.join({ url });
38
38
 
39
- this.call.on(
40
- "remote-participants-audio-level",
41
- (participantsAudioLevel) =>
42
- this.handleParticipantsAudioLevel(participantsAudioLevel)
39
+ this.call.on("active-speaker-change", (e) =>
40
+ this.handleSpeakerChange(e)
43
41
  );
44
- this.call.startRemoteParticipantsAudioLevelObserver(500);
45
42
  })
46
43
  .catch((error) => {
47
44
  console.error(error);
48
45
  });
49
46
  }
50
47
 
51
- private handleParticipantsAudioLevel(participantsAudioLevel: any[]) {
52
- const level = Object.values(participantsAudioLevel).reduce(
53
- (a, b) => a + b,
54
- 0
55
- );
56
- console.log(level);
48
+ private handleSpeakerChange(speaker: any) {
49
+ console.log(speaker);
50
+ console.log(this.call?.participants());
51
+ if (speaker?.userId === this.call?.participants()?.local?.user_id) {
52
+ this.emit("speech-end");
53
+ } else {
54
+ this.emit("speech-start");
55
+ }
57
56
  }
58
57
 
59
58
  stop(): void {