@vapi-ai/web 1.0.188 → 1.0.190
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 +0 -1
- package/dist/vapi.js +22 -11
- package/package.json +1 -1
- package/vapi.ts +21 -15
package/dist/vapi.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export default class Vapi extends EventEmitter {
|
|
|
7
7
|
private speakingTimeout;
|
|
8
8
|
constructor(apiToken: string, apiBaseUrl?: string);
|
|
9
9
|
start(assistant: CreateAssistantDTO | string): void;
|
|
10
|
-
private handleParticipantUpdated;
|
|
11
10
|
private handleRemoteParticipantsAudioLevel;
|
|
12
11
|
stop(): void;
|
|
13
12
|
}
|
package/dist/vapi.js
CHANGED
|
@@ -45,8 +45,28 @@ class Vapi extends events_1.default {
|
|
|
45
45
|
this.call.on("left-meeting", () => {
|
|
46
46
|
this.emit("call-end");
|
|
47
47
|
});
|
|
48
|
-
this.call.on("
|
|
49
|
-
|
|
48
|
+
this.call.on("error", () => {
|
|
49
|
+
// Don't print to console
|
|
50
|
+
});
|
|
51
|
+
this.call.on("track-started", (e) => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
if (((_a = e === null || e === void 0 ? void 0 : e.participant) === null || _a === void 0 ? void 0 : _a.user_name) !== "Vapi Speaker")
|
|
54
|
+
return;
|
|
55
|
+
(_b = this.call) === null || _b === void 0 ? void 0 : _b.sendAppMessage("playable");
|
|
56
|
+
this.emit("call-start");
|
|
57
|
+
});
|
|
58
|
+
this.call.on("participant-joined", (e) => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
if ((e === null || e === void 0 ? void 0 : e.participant.user_name) !== "Vapi Speaker")
|
|
61
|
+
return;
|
|
62
|
+
(_a = this.call) === null || _a === void 0 ? void 0 : _a.updateParticipant((_b = e === null || e === void 0 ? void 0 : e.participant.user_id) !== null && _b !== void 0 ? _b : "", {
|
|
63
|
+
setSubscribedTracks: {
|
|
64
|
+
audio: true,
|
|
65
|
+
video: false,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
yield this.call.join({ url, subscribeToTracksAutomatically: false });
|
|
50
70
|
this.call.startRemoteParticipantsAudioLevelObserver();
|
|
51
71
|
this.call.on("remote-participants-audio-level", (e) => this.handleRemoteParticipantsAudioLevel(e));
|
|
52
72
|
}))
|
|
@@ -54,15 +74,6 @@ class Vapi extends events_1.default {
|
|
|
54
74
|
console.error(error);
|
|
55
75
|
});
|
|
56
76
|
}
|
|
57
|
-
handleParticipantUpdated(e) {
|
|
58
|
-
var _a;
|
|
59
|
-
if (e &&
|
|
60
|
-
e.participant.user_name === "Vapi Speaker" &&
|
|
61
|
-
e.participant.tracks.audio.state === "playable") {
|
|
62
|
-
(_a = this.call) === null || _a === void 0 ? void 0 : _a.sendAppMessage("playable");
|
|
63
|
-
this.emit("call-start");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
77
|
handleRemoteParticipantsAudioLevel(e) {
|
|
67
78
|
const isSpeaking = Object.values(e.participantsAudioLevel).some((v) => v > 0.01);
|
|
68
79
|
if (!isSpeaking)
|
package/package.json
CHANGED
package/vapi.ts
CHANGED
|
@@ -45,11 +45,28 @@ export default class Vapi extends EventEmitter {
|
|
|
45
45
|
this.emit("call-end");
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
this.call.on("
|
|
49
|
-
|
|
50
|
-
);
|
|
48
|
+
this.call.on("error", () => {
|
|
49
|
+
// Don't print to console
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this.call.on("track-started", (e) => {
|
|
53
|
+
if (e?.participant?.user_name !== "Vapi Speaker") return;
|
|
54
|
+
this.call?.sendAppMessage("playable");
|
|
55
|
+
this.emit("call-start");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
this.call.on("participant-joined", (e) => {
|
|
59
|
+
if (e?.participant.user_name !== "Vapi Speaker") return;
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
this.call?.updateParticipant(e?.participant.user_id ?? "", {
|
|
62
|
+
setSubscribedTracks: {
|
|
63
|
+
audio: true,
|
|
64
|
+
video: false,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
await this.call.join({ url, subscribeToTracksAutomatically: false });
|
|
53
70
|
|
|
54
71
|
this.call.startRemoteParticipantsAudioLevelObserver();
|
|
55
72
|
this.call.on("remote-participants-audio-level", (e) =>
|
|
@@ -61,17 +78,6 @@ export default class Vapi extends EventEmitter {
|
|
|
61
78
|
});
|
|
62
79
|
}
|
|
63
80
|
|
|
64
|
-
private handleParticipantUpdated(e: DailyEventObjectParticipant | undefined) {
|
|
65
|
-
if (
|
|
66
|
-
e &&
|
|
67
|
-
e.participant.user_name === "Vapi Speaker" &&
|
|
68
|
-
e.participant.tracks.audio.state === "playable"
|
|
69
|
-
) {
|
|
70
|
-
this.call?.sendAppMessage("playable");
|
|
71
|
-
this.emit("call-start");
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
81
|
private handleRemoteParticipantsAudioLevel(
|
|
76
82
|
e: DailyEventObjectRemoteParticipantsAudioLevel
|
|
77
83
|
) {
|