@vapi-ai/web 1.0.152 → 1.0.154

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,5 +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
10
  stop(): void;
10
11
  }
package/dist/vapi.js CHANGED
@@ -25,20 +25,27 @@ class Vapi extends events_1.default {
25
25
  assistantId: typeof assistant === "string" ? assistant : undefined,
26
26
  })
27
27
  .then(({ data }) => {
28
+ var _a;
28
29
  const { url } = data;
29
30
  this.call = daily_js_1.default.createFrame({
30
31
  audioSource: true,
31
32
  videoSource: false,
32
33
  });
34
+ (_a = this.call.iframe()) === null || _a === void 0 ? void 0 : _a.style.setProperty("display", "none");
33
35
  this.call.join({ url });
34
- this.call.on("joined-meeting", () => {
35
- console.log("JOINED");
36
- });
36
+ this.call.on("remote-participants-audio-level", ({ participantsAudioLevel }) => this.handleParticipantsAudioLevel(participantsAudioLevel));
37
+ this.call.startRemoteParticipantsAudioLevelObserver(500);
37
38
  })
38
39
  .catch((error) => {
39
40
  console.error(error);
40
41
  });
41
42
  }
43
+ handleParticipantsAudioLevel(participantsAudioLevel) {
44
+ if (!participantsAudioLevel)
45
+ return;
46
+ const level = Object.values(participantsAudioLevel).reduce((a, b) => a + b, 0);
47
+ console.log(level);
48
+ }
42
49
  stop() {
43
50
  var _a;
44
51
  this.started = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.152",
3
+ "version": "1.0.154",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/vapi.ts CHANGED
@@ -33,16 +33,30 @@ export default class Vapi extends EventEmitter {
33
33
  audioSource: true,
34
34
  videoSource: false,
35
35
  });
36
+ this.call.iframe()?.style.setProperty("display", "none");
36
37
  this.call.join({ url });
37
- this.call.on("joined-meeting", () => {
38
- console.log("JOINED");
39
- });
38
+
39
+ this.call.on(
40
+ "remote-participants-audio-level",
41
+ ({ participantsAudioLevel }) =>
42
+ this.handleParticipantsAudioLevel(participantsAudioLevel)
43
+ );
44
+ this.call.startRemoteParticipantsAudioLevelObserver(500);
40
45
  })
41
46
  .catch((error) => {
42
47
  console.error(error);
43
48
  });
44
49
  }
45
50
 
51
+ private handleParticipantsAudioLevel(participantsAudioLevel: any[]) {
52
+ if (!participantsAudioLevel) return;
53
+ const level = Object.values(participantsAudioLevel).reduce(
54
+ (a, b) => a + b,
55
+ 0
56
+ );
57
+ console.log(level);
58
+ }
59
+
46
60
  stop(): void {
47
61
  this.started = false;
48
62
  this.call?.destroy();