when the agent is speaking I am trying to cut the agent in between using a button and not able to do it. I have tried different data channel events like ‘response.cancel’, ‘conversation.item.truncate’, ‘conversation.item.deleted’ but none of them are working
This is my function being called on a button click
function stopAgentAudio() {
if (datachannelRef.current && datachannelRef.current.readyState === “open”) {
const truncateEvent = {
“type”: “response.cancel”
};
datachannelRef.current.send(JSON.stringify(truncateEvent));
console.log(“Sent cancel event:”, truncateEvent);
} else {
console.warn(“DataChannel is not open [stopAgentAudio]”);
}
}
Stop Audio
If anyone could suggest a way to stop the agent mid response it would be great.