STConversationCallback
Receives application-facing events, decisions, and state changes from an executing Conversation.
public protocol STConversationCallback: AnyObject {
func conversationModuleWillStart(moduleID: String)
func conversationModuleWillEnd(moduleID: String)
func conversationReceivedSpeechRecognition(moduleID: String, data: STSRData)
func conversationReceivedMediaEvent(moduleID: String, event: STMediaEvent)
func conversationRequestsAudioSegment(moduleID: String, promptID: String) -> Bool
func conversationDidSubmitAudioSegment(moduleID: String, promptID: String, audioSegment: STAudioSegment)
func conversationReceivedPermissionResult(permission: STMediaPermission, status: STPermissionStatus)
func conversationProcessingPaused(moduleID: String)
func conversationProcessingResumed(moduleID: String)
func conversationAudioProcessingBecameUnavailable(moduleID: String)
func conversationAudioProcessingBecameAvailable(moduleID: String)
}
Every requirement has a default implementation. Applications implement only the callbacks they need. conversationRequestsAudioSegment(moduleID:promptID:) defaults to false; the remaining defaults do nothing.
Module lifecycle
conversationModuleWillStart(moduleID:) runs before processing of a Conversation module begins. conversationModuleWillEnd(moduleID:) reports that module processing is ending.
For any callback, if the application updates runtime fields that must affect the framework’s immediate next action, complete those updates synchronously before returning.
Speech recognition
conversationReceivedSpeechRecognition(moduleID:data:) delivers STSRData for recognition associated with a Conversation module.
This is a decision-capable callback, not merely a UI notification. The application can inspect a hypothesis, update runtime fields/user intent, or mark the hypothesis rejected through clientRejectedHypothesis. When the current Conversation decision depends on one of those changes, complete it synchronously before the callback returns.
Media events
conversationReceivedMediaEvent(moduleID:event:) exposes the same typed STMediaEvent model documented by STMediaRunner, but associated with the active Conversation module. Use the STMediaRunner Media Events reference for event-function, event-type, and typed-payload semantics.
Application-provided audio
conversationRequestsAudioSegment(moduleID:promptID:) asks whether the application intends to supply the requested prompt audio. Returning false is the default behavior.
conversationDidSubmitAudioSegment(moduleID:promptID:audioSegment:) reports the submitted segment associated with the module and prompt.
Permissions
conversationReceivedPermissionResult(permission:status:) reports resolved microphone or speech-recognition permission state. The current runner forwards permission events after updating its own Conversation-manager permission state.
Conversation processing
conversationProcessingPaused(moduleID:) and conversationProcessingResumed(moduleID:) report Conversation processing state changes.
Audio-processing availability
conversationAudioProcessingBecameUnavailable(moduleID:) and conversationAudioProcessingBecameAvailable(moduleID:) let the host application observe temporary availability of audio processing required by the Conversation.
Concurrency guidance
Do not indiscriminately dispatch every callback to the UI thread before doing Conversation-critical work. Runtime-field changes, user-intent changes, and clientRejectedHypothesis decisions that affect the framework's immediate next action must happen before the relevant callback returns. UI updates can be published separately.