This topic describes how to use AICallKit SDK to interrupt an intelligent agent during its speech.
How to interrupt
You can interrupt the speech of the intelligent agent by using one of the following methods:
Manual interruption
Manual interruption: sends an interrupt message to the intelligent agent that is speaking. Upon receiving the message, the agent stops answering the current question. To enable manual interruption, call interruptSpeaking
in AICallKit SDK.
Intelligent interruption
Intelligent interruption: interrupts the voice output of an intelligent agent with new voice inputs. For example, if a user asks Question B while the agent is still answering Question A, the agent will stop answering Question A and begin answering Question B instead. To enable intelligent interruption, call enableVoiceInterrupt
in AICallKit SDK. The status of intelligent interruption is indicated by the onVoiceInterrupted
callback.
Sample code
mARTCAICallEngine.enableVoiceInterrupt(false);
mARTCAICallEngine.interruptSpeaking();
ARTCAICallEngine.IARTCAICallEngineCallback mCallEngineCallbackWrapper = new ARTCAICallEngine.IARTCAICallEngineCallback() {
@Override
public void onVoiceInterrupted(boolean enable) {
}
}
_ = self.engine.enableVoiceInterrupt(enable: false)
_ = self.engine.interruptSpeaking()
func onVoiceInterrupted(enable: Bool) {
}
engine.enableVoiceInterrupt(false);
engine.interruptSpeaking();
engine.on('voiceInterruptChanged', (ennable) => {
console.log('AICallVoiceInterruptChanged', ennable);
});
Interruption by using a designated keyword
During a call with an intelligent agent, users can interrupt the agent by using a designated keyword. The keyword typically needs to be configured when you start the agent.
Sample code
ARTCAICallEngine.ARTCAICallConfig artcaiCallConfig = new ARTCAICallEngine.ARTCAICallConfig();
artcaiCallConfig.mAiCallAgentTemplateConfig.interruptWords.add("Excuse me");
artcaiCallConfig.mAiCallAgentTemplateConfig.interruptWords.add("Test interruption");
@Override
public void onSpeakingInterrupted(ARTCAICallEngine.ARTCAICallSpeakingInterruptedReason reason) {
}
let templateConfig = ARTCAICallTemplateConfig()
templateConfig.interruptWords = ["Excuse me", "xxxx"]
let controller = AUIAICallStandardController(userId: userId)
controller.config.templateConfig = templateConfig
...
let jsonString = templateConfig.getJsonString(agentType)
...
public func onSpeakingInterrupted(reason: ARTCAICallSpeakingInterruptedReason) {
}