Discussions
How to get full avatar message?
3 months ago by Stalin Raj
I am using this code to get the content that avatar speaks.
avatar.on(StreamingEvents.AVATAR_TALKING_MESSAGE, (message) => {
console.log("avatar message", message)
});
// Start voice chat
await avatar.startVoiceChat({ useSilencePrompt: false });
// Welcome message
const welcomeMessage = "Hi There! Welcome! How can I assist you?";
await avatar.speak({
text: welcomeMessage,
taskType: TaskType.REPEAT,
taskMode: TaskMode.SYNC,
});
Initially am getting the text of avatar talking in a single object. Below is my console:
avatar message
CustomEvent {
detail: {
"type": "avatar_talking_message",
"task_id": "bbc46d91-d975-11ef-9640-72615a2b266a",
"message": "Hi There! Welcome To Docketry! How can I assist you?"
}
};
But when I ask a question in voice mode and got the answer from avatar, that time the answer is given in chunks.
For example: Sorry! I don't know
avatar message
CustomEvent {
detail: {
"type": "avatar_talking_message",
"task_id": "bbc46d91-d975-11ef-9640-72615a2b266a",
"message": "Sorry"
}
};
avatar message
CustomEvent {
detail: {
"type": "avatar_talking_message",
"task_id": "bbc46d91-d975-11ef-9640-72615a2b266a",
"message": "!"
}
};
avatar message
CustomEvent {
detail: {
"type": "avatar_talking_message",
"task_id": "bbc46d91-d975-11ef-9640-72615a2b266a",
"message": "I"
}
};
avatar message
CustomEvent {
detail: {
"type": "avatar_talking_message",
"task_id": "bbc46d91-d975-11ef-9640-72615a2b266a",
"message": "don't"
}
};
avatar message
CustomEvent {
detail: {
"type": "avatar_talking_message",
"task_id": "bbc46d91-d975-11ef-9640-72615a2b266a",
"message": "know"
}
};
Why like that? It is very hard to get each part of answer to get the transcript.
Is there anything to resolve this?
My requirement is to show the transcript of both user and avatar conversations.