Handling the signalling to play the audio
This commit is contained in:
@@ -89,13 +89,19 @@ class ChatbotClient {
|
|||||||
});
|
});
|
||||||
this.dailyCallObject.on("track-started", (evt) => {
|
this.dailyCallObject.on("track-started", (evt) => {
|
||||||
if (evt.track.kind === "audio" && evt.participant.local === false) {
|
if (evt.track.kind === "audio" && evt.participant.local === false) {
|
||||||
|
this.log("Audio track started.")
|
||||||
this.setupAudioTrack(evt.track);
|
this.setupAudioTrack(evt.track);
|
||||||
|
this.log("Will send the audio message to play the audio")
|
||||||
|
this.dailyCallObject.sendAppMessage("playable")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.dailyCallObject.on("track-stopped", this.handleEventToConsole.bind(this));
|
this.dailyCallObject.on("track-stopped", this.handleEventToConsole.bind(this));
|
||||||
this.dailyCallObject.on("participant-joined", this.handleEventToConsole.bind(this));
|
this.dailyCallObject.on("participant-joined", this.handleEventToConsole.bind(this));
|
||||||
this.dailyCallObject.on("participant-updated", this.handleEventToConsole.bind(this));
|
this.dailyCallObject.on("participant-updated", this.handleEventToConsole.bind(this));
|
||||||
this.dailyCallObject.on("participant-left", this.handleEventToConsole.bind(this));
|
this.dailyCallObject.on("participant-left", () => {
|
||||||
|
// When the bot leaves, we are also disconnecting from the call
|
||||||
|
this.disconnect()
|
||||||
|
});
|
||||||
this.dailyCallObject.on("left-meeting", () => {
|
this.dailyCallObject.on("left-meeting", () => {
|
||||||
this.updateStatus('Disconnected');
|
this.updateStatus('Disconnected');
|
||||||
this.connectBtn.disabled = false;
|
this.connectBtn.disabled = false;
|
||||||
@@ -185,6 +191,7 @@ class ChatbotClient {
|
|||||||
try {
|
try {
|
||||||
// Disconnect the RTVI client
|
// Disconnect the RTVI client
|
||||||
await this.dailyCallObject.leave();
|
await this.dailyCallObject.leave();
|
||||||
|
await this.dailyCallObject.destroy();
|
||||||
this.dailyCallObject = null;
|
this.dailyCallObject = null;
|
||||||
|
|
||||||
// Clean up audio
|
// Clean up audio
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ async def main():
|
|||||||
@transport.event_handler("on_app_message")
|
@transport.event_handler("on_app_message")
|
||||||
async def on_app_message(transport, message, sender):
|
async def on_app_message(transport, message, sender):
|
||||||
logger.debug(f"Received app message: {message} - {sender}")
|
logger.debug(f"Received app message: {message} - {sender}")
|
||||||
if "message" not in message:
|
if "playable" not in message:
|
||||||
return
|
return
|
||||||
await task.queue_frames(
|
await task.queue_frames(
|
||||||
[TTSSpeakFrame(f"Hello there, how are you doing today ?"), EndFrame()]
|
[TTSSpeakFrame(f"Hello there, how are you doing today ?"), EndFrame()]
|
||||||
|
|||||||
Reference in New Issue
Block a user