@vapi-ai/web 1.0.184 → 1.0.185
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 +1 -0
- package/dist/vapi.js +9 -0
- package/package.json +1 -1
- package/vapi.ts +15 -0
package/dist/vapi.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ 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;
|
|
10
11
|
private handleRemoteParticipantsAudioLevel;
|
|
11
12
|
stop(): void;
|
|
12
13
|
}
|
package/dist/vapi.js
CHANGED
|
@@ -48,6 +48,7 @@ class Vapi extends events_1.default {
|
|
|
48
48
|
this.call.on("left-meeting", () => {
|
|
49
49
|
this.emit("call-end");
|
|
50
50
|
});
|
|
51
|
+
this.call.on("participant-updated", (e) => this.handleParticipantUpdated(e));
|
|
51
52
|
yield this.call.join({ url });
|
|
52
53
|
this.call.startRemoteParticipantsAudioLevelObserver();
|
|
53
54
|
this.call.on("remote-participants-audio-level", (e) => this.handleRemoteParticipantsAudioLevel(e));
|
|
@@ -56,6 +57,14 @@ class Vapi extends events_1.default {
|
|
|
56
57
|
console.error(error);
|
|
57
58
|
});
|
|
58
59
|
}
|
|
60
|
+
handleParticipantUpdated(e) {
|
|
61
|
+
var _a;
|
|
62
|
+
if (e &&
|
|
63
|
+
e.participant.user_name === "Vapi Speaker" &&
|
|
64
|
+
e.participant.tracks.audio.state === "playable") {
|
|
65
|
+
(_a = this.call) === null || _a === void 0 ? void 0 : _a.sendAppMessage("playable");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
59
68
|
handleRemoteParticipantsAudioLevel(e) {
|
|
60
69
|
const isSpeaking = Object.values(e.participantsAudioLevel).some((v) => v > 0.01);
|
|
61
70
|
if (!isSpeaking)
|
package/package.json
CHANGED
package/vapi.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import DailyIframe, {
|
|
2
2
|
DailyCall,
|
|
3
3
|
DailyEventObjectActiveSpeakerChange,
|
|
4
|
+
DailyEventObjectParticipant,
|
|
4
5
|
DailyEventObjectRemoteParticipantsAudioLevel,
|
|
5
6
|
} from "@daily-co/daily-js";
|
|
6
7
|
|
|
@@ -47,6 +48,10 @@ export default class Vapi extends EventEmitter {
|
|
|
47
48
|
this.emit("call-end");
|
|
48
49
|
});
|
|
49
50
|
|
|
51
|
+
this.call.on("participant-updated", (e) =>
|
|
52
|
+
this.handleParticipantUpdated(e)
|
|
53
|
+
);
|
|
54
|
+
|
|
50
55
|
await this.call.join({ url });
|
|
51
56
|
|
|
52
57
|
this.call.startRemoteParticipantsAudioLevelObserver();
|
|
@@ -59,6 +64,16 @@ export default class Vapi extends EventEmitter {
|
|
|
59
64
|
});
|
|
60
65
|
}
|
|
61
66
|
|
|
67
|
+
private handleParticipantUpdated(e: DailyEventObjectParticipant | undefined) {
|
|
68
|
+
if (
|
|
69
|
+
e &&
|
|
70
|
+
e.participant.user_name === "Vapi Speaker" &&
|
|
71
|
+
e.participant.tracks.audio.state === "playable"
|
|
72
|
+
) {
|
|
73
|
+
this.call?.sendAppMessage("playable");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
private handleRemoteParticipantsAudioLevel(
|
|
63
78
|
e: DailyEventObjectRemoteParticipantsAudioLevel
|
|
64
79
|
) {
|