Overview
TheinterruptPersona() method allows you to programmatically stop the persona while it’s speaking.
Requires SDK version 3.4.0 or higher
Method Signature
Basic Usage
Stop the persona from speaking immediately:Prerequisites
Before callinginterruptPersona(), you must:
- Have an active streaming session (call
stream()orstreamToVideoElement()first) - Have successfully connected to the Anam Engine
Error Handling
The method throws errors in the following cases:| Error Message | Cause |
|---|---|
Failed to send interrupt command: not currently streaming | Called before starting a stream or after stopping |
Failed to send interrupt command: no active session | No session ID available |
Behavior
TheinterruptPersona() method:
- Immediately stops any ongoing speech from the persona
- The persona remains ready to receive new input after being interrupted
- Has no effect if the persona is not currently speaking (no error thrown in this case)
Use Cases
User-Initiated Interruption
Allow users to interrupt the persona when they want to ask a different question or change topics:Voice activity detection automatically interrupts the persona when the user starts speaking. Use this method for programmatic interruption or when you need immediate response to UI actions.

