@vapi-ai/web 1.0.173 → 1.0.175

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
@@ -4,7 +4,6 @@ import EventEmitter from "events";
4
4
  export default class Vapi extends EventEmitter {
5
5
  private started;
6
6
  private call;
7
- private speaking;
8
7
  constructor(apiToken: string, apiBaseUrl?: string);
9
8
  start(assistant: CreateAssistantDTO | string): void;
10
9
  private handleRemoteParticipantsAudioLevel;
package/dist/vapi.js CHANGED
@@ -20,7 +20,6 @@ class Vapi extends events_1.default {
20
20
  super();
21
21
  this.started = false;
22
22
  this.call = null;
23
- this.speaking = false;
24
23
  client_1.client.baseUrl = apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : "https://api.vapi.ai";
25
24
  client_1.client.setSecurityData(apiToken);
26
25
  }
@@ -44,26 +43,15 @@ class Vapi extends events_1.default {
44
43
  (_a = this.call.iframe()) === null || _a === void 0 ? void 0 : _a.style.setProperty("display", "none");
45
44
  yield this.call.join({ url });
46
45
  this.call.startRemoteParticipantsAudioLevelObserver();
47
- this.call.on("remote-participants-audio-level", this.handleRemoteParticipantsAudioLevel);
46
+ this.call.on("remote-participants-audio-level", (e) => this.handleRemoteParticipantsAudioLevel(e));
48
47
  }))
49
48
  .catch((error) => {
50
49
  console.error(error);
51
50
  });
52
51
  }
53
52
  handleRemoteParticipantsAudioLevel(e) {
54
- const isSpeaking = Object.values(e.participantsAudioLevel).some((v) => v > 0.01);
55
- console.log(isSpeaking);
56
- if (isSpeaking === this.speaking)
57
- return;
58
- if (isSpeaking) {
59
- console.log("start");
60
- this.emit("speech-start");
61
- }
62
- else {
63
- console.log("end");
64
- this.emit("speech-end");
65
- }
66
- this.speaking = isSpeaking;
53
+ const volume = Object.values(e.participantsAudioLevel).reduce((acc, curr) => acc + curr, 0);
54
+ this.emit("speech-volume", volume);
67
55
  }
68
56
  stop() {
69
57
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.173",
3
+ "version": "1.0.175",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/vapi.ts CHANGED
@@ -11,7 +11,6 @@ import { client } from "./client";
11
11
  export default class Vapi extends EventEmitter {
12
12
  private started: boolean = false;
13
13
  private call: DailyCall | null = null;
14
- private speaking = false;
15
14
 
16
15
  constructor(apiToken: string, apiBaseUrl?: string) {
17
16
  super();
@@ -42,9 +41,8 @@ export default class Vapi extends EventEmitter {
42
41
  await this.call.join({ url });
43
42
 
44
43
  this.call.startRemoteParticipantsAudioLevelObserver();
45
- this.call.on(
46
- "remote-participants-audio-level",
47
- this.handleRemoteParticipantsAudioLevel
44
+ this.call.on("remote-participants-audio-level", (e) =>
45
+ this.handleRemoteParticipantsAudioLevel(e)
48
46
  );
49
47
  })
50
48
  .catch((error) => {
@@ -55,21 +53,11 @@ export default class Vapi extends EventEmitter {
55
53
  private handleRemoteParticipantsAudioLevel(
56
54
  e: DailyEventObjectRemoteParticipantsAudioLevel
57
55
  ) {
58
- const isSpeaking = Object.values(e.participantsAudioLevel).some(
59
- (v) => v > 0.01
56
+ const volume = Object.values(e.participantsAudioLevel).reduce(
57
+ (acc, curr) => acc + curr,
58
+ 0
60
59
  );
61
- console.log(isSpeaking);
62
- if (isSpeaking === this.speaking) return;
63
-
64
- if (isSpeaking) {
65
- console.log("start");
66
- this.emit("speech-start");
67
- } else {
68
- console.log("end");
69
- this.emit("speech-end");
70
- }
71
-
72
- this.speaking = isSpeaking;
60
+ this.emit("speech-volume", volume);
73
61
  }
74
62
 
75
63
  stop(): void {