STVoiceFlowCallback Protocol Reference
| Declared in | STVoiceFlowCallback.swift |
Overview
The STVoiceFlowCallback protocol defines the optional callback methods implemented by an application class that subclasses this protocol in order to receive real time callbacks with events and data during Voiceflow processing from STVoiceFlowRunner module . A class initializing an instance of STVoiceFlowRunner must be a subclass of STVoiceFlowCallback and must provide implementation of the protocol methods in order to receive Voiceflow processing callbacks from STVoiceFlowRunner module.
Note: Voiceflow processing generating callbacks from STVoiceFlowRunner module cover most of the events needed by an application including a subset of realtime event notifications from STMediaRunner module. For a complete set of realtime media event notifications from STMediaRunner module, the application must implement STMedia_EventNotification function defined in STEventsObserverDelegate protocol.
Note: VoiceFfow processing callbacks from STVoiceFlowRunner module occur on the main thread of an application. The application should be careful not to tie its main thread with complex and time consuming tasks so these callbacks and events are received timely. Also the application should release the callback and event notfication methods quickly without leveraging these methods to execute complex and time comsuming tasks.
Sample implementation code:
#import STVoiceFlow
public final class MyVoiceFlowClass: NSObject, STVoiceFlowCallback {
var voiceFlowRunner: STVoiceFlowRunner? = nil
func initializeSTVoiceFlowRunner () {
voiceFlowRunner = STVoiceFlowRunner()
_ = voiceFlowRunner.initialize()
voiceFlowRunner!.setVoiceFlowCallback(self)
}
// Optional implementation of callback methods from STVoiceFlowCallback protocol
func STVFC_PreModuleStart(vfModuleID: String) {
}
func STVFC_PreModuleEnd(vfModuleID: String) {
}
func STVFC_SRHypothesis(vfModuleID: String, srData: STSRData) {
}
func STVFC_MediaEvent(vfModuleID: String, mediaItemID: String, mediaFunction:STNotifyMediaFunction, mediaEvent:STNotifyMediaEvent, mediaEventData: [AnyHashable : Any]) {
}
func STVFC_PlayAudioSegmentData(vfModuleID: String, promptID:String, audioSegmentType:STAudioSegmentType, audioFile: String?, textString: String?, textFile: String?) {
}
func STVFC_PermissionEvent(permissionEvent:STNotifyMediaEvent) {
}
}
Tasks
-
– STVFC_PreModuleStartCall back to application just before Voiceflow processing of a Voiceflow module starts.
-
– STVFC_PreModuleEndCall back to application just before Voiceflow processing of a Voiceflow module ends.
-
– STVFC_SRHypothesisCall back to application with speech recognition data genrated by an SR Hypothesis.
-
– STVFC_MediaEventCall back to application with media event notifications.
-
– STVFC_PlayAudioSegmentDataCall back to application with an event notifcation indicating the start of audio playback of an audio segment.
-
– STVFC_PermissionEventCall back to application with the result of a permission request.
permissionEventcan have one of the following value:- STNotifyMediaEvent.NME_MICROPHONE_PERMISSION_GRANTED - STNotifyMediaEvent.NME_MICROPHONE_PERMISSION_DENIED - STNotifyMediaEvent.NME_SPEECHRECOGNIZER_PERMISSION_GRANTED - STNotifyMediaEvent.NME_SPEECHRECOGNIZER_PERMISSION_DENIED
Instance Methods
STVFC_MediaEvent
func STVFC_MediaEvent
Discussion
Call back to application with media event notifications.
Parameters
vfModuleIDThe Voice Flow module ID.
mediaItemIDThe ID of the media item being processed for which this media event notification applies.
mediaFunctionThe media function.
mediaEventThe media event.
mediaEventDataThe media event data.
Declared In
STVoiceFlowCallback.swift
STVFC_PermissionEvent
func STVFC_PermissionEvent
Discussion
Call back to application with the result of a permission request. permissionEvent can have one of the following value:
- STNotifyMediaEvent.NME_MICROPHONE_PERMISSION_GRANTED
- STNotifyMediaEvent.NME_MICROPHONE_PERMISSION_DENIED
- STNotifyMediaEvent.NME_SPEECHRECOGNIZER_PERMISSION_GRANTED
- STNotifyMediaEvent.NME_SPEECHRECOGNIZER_PERMISSION_DENIED
Parameters
permissionEventThe result of the permission request.
Declared In
STVoiceFlowCallback.swift
STVFC_PlayAudioSegmentData
func STVFC_PlayAudioSegmentData
Discussion
Call back to application with an event notifcation indicating the start of audio playback of an audio segment.
Parameters
vfModuleIDThe Voice Flow module ID.
promptIDThe audio prompt module ID.
promptTypeThe audio segment type.
audioFileThe file name of the recorded audio file processed for audio playback.
textStringThe text processed for audio playback.
textFileThe file name of the text file containing the text processed for audio playback.
Declared In
STVoiceFlowCallback.swift
STVFC_PreModuleEnd
func STVFC_PreModuleEnd
Discussion
Call back to application just before Voiceflow processing of a Voiceflow module ends.
Parameters
vfModuleIDThe Voice Flow module ID.
Declared In
STVoiceFlowCallback.swift