이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

인터럽트 명령

Feature Overview

Clients can proactively interrupt the AI bot's speech output—instantly stopping voice playback and clearing any queued audio. This action has the same effect as sending the Interrupt command through the server-side ControlVoiceConversation API.

Implementation

Connect to Bot

Note:
Before invoking the interrupt command, ensure you have connected to the bot using connect. For integration details, see: Client: Connecting AI Bot.

Initiate Interrupt

Call TRTCCloud.callExperimentalAPI:
{
"api": "aiConversation",
"params": {
"command": "interrupt",
"robotid": "ai_bot_001"
}
}
Set robotid to the UserId of the currently connected AI bot.
If the interruption succeeds, no callback is triggered. If the operation fails, the error will be reported via the TRTCCloudListener.onExperimentalEvent callback, with eventName set to onAIConversationEvent and params as follows:
{
"event": "onCommand",
"robotid": "ai_bot_001",
"command": "interrupt",
"errCode": 1004,
"errMsg": "invalid state"
}
errCode
Description
-2
Parameter error: missing robotid.
-3
The robotid provided does not match the currently connected bot.
1001
Task has ended; no further response.
1002
Server processing failed; you may retry.
1003
Invalid command parameters.
1004
Current state does not allow interruption. For example, the AI is not speaking, the task has ended, or the session has not started.

About Interrupt Modes

When creating a task, DialogConfig.InterruptMode specifies when the server will automatically interrupt playback. Both the client-side interrupt and server-side ControlVoiceConversation Interrupt commands are active forced interrupts and are not limited by this mode.
InterruptMode
Description
0 (default)
Automatic interrupt: When user speech is detected, playback is interrupted. The minimum speech duration is controlled by InterruptSpeechDuration, which ranges from 200 to 3000 milliseconds (default: 200 ms).
1
Manual interrupt: Playback is interrupted only when a server-side Interrupt or client-side interrupt command is received.
2
Keyword interrupt: Playback is interrupted when the user speaks a word contained in InterruptKeywords (up to 128 keywords).