BZVoiceFlowCallback Protocol Reference
| Declared in | BZVoiceFlowCallback.swift |
Overview
The BZVoiceFlowCallback protocol defines the optional callback methods implemented by an application class that subclasses this protocol in order to receive real time callbacks with events during Voiceflow processing from BZVoiceFlow framework . A class initializing an instance of BZVoiceFlowController must be a subclass of BZVoiceFlowCallback and must provide implementation of the protocol methods in order to receive Voiceflow processing callbacks from BZVoiceFlow Framework.
Note: Voiceflow processing generating callbacks from BZVoiceFlow framework cover most of the events needed by an application including a subset of realtime event notifications from BZMedia framework. For a complete set of realtime event notifications from BZMedia framework, the application must implement bzMedia_EventNotification function from BZEventsObserverDelegate.
Note: VoiceFfow processing callbacks from BZVoiceFlow framework 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 BZVoiceFlow_Framework
public final class MyVoiceFlowClass: NSObject, BZVoiceFlowCallback {
var bzEventsObserver: BZEventsObserver? = nil
var bzVoiceFlowController: BZVoiceFlowController? = nil
func InitializeBZVoiceFlowController () {
bzVoiceFlowController = BZVoiceFlowController()
_ = bzVoiceFlowController.initialize()
bzVoiceFlowController!.setVoiceFlowCallback(self)
}
// Optional implementation of callback methods from BZVoiceFlowCallback protocol
func BZVFC_PreModuleStart(vfModuleID: String) {
}
func BZVFC_PreModuleEnd(vfModuleID: String) {
}
func BZVFC_SRHypothesis(vfModuleID: String, srData: BZSRData) {
}
func BZVFC_MediaEvent(vfModuleID: String, mediaItemID: String, mediaFunction:BZNotifyMediaFunction, mediaEvent:BZNotifyMediaEvent, mediaEventData: [AnyHashable : Any]) {
}
func BZVFC_PlayAudioSegmentData(vfModuleID: String, promptID:String, audioSegmentType:BZAudioSegmentType, audioFile: String?, textString: String?, textFile: String?) {
}
func BZVFC_PermissionEvent(permissionEvent:BZNotifyMediaEvent) {
}
}
Tasks
-
– BZVFC_PreModuleStartCall back to application just before Voiceflow processing of a Voiceflow module starts.
-
– BZVFC_PreModuleEndCall back to application just before Voiceflow processing of a Voiceflow module ends.
-
– BZVFC_SRHypothesisCall back to application with speech recognition data genrated by an SR Hypothesis.
-
– BZVFC_MediaEventCall back to application with media event notification.
-
– BZVFC_PlayAudioSegmentDataCall back to application with an event notifcation indicating the start of audio playback of an audio segment.
-
– BZVFC_PermissionEventCall back to application with the result of a permission request.
permissionEventcan have one of the following value:- BZNotifyMediaEvent.NME_MICROPHONE_PERMISSION_GRANTED - BZNotifyMediaEvent.NME_MICROPHONE_PERMISSION_DENIED - BZNotifyMediaEvent.NME_SPEECHRECOGNIZER_PERMISSION_GRANTED - BZNotifyMediaEvent.NME_SPEECHRECOGNIZER_PERMISSION_DENIED
Instance Methods
BZVFC_MediaEvent
func BZVFC_MediaEvent(vfModuleID: String, mediaItemID: String, mediaFunction:BZNotifyMediaFunction, mediaEvent:BZNotifyMediaEvent, mediaEventData: [AnyHashable : Any])
Discussion
Call back to application with media event notification.
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
BZVoiceFlowCallback.swift
BZVFC_PermissionEvent
func BZVFC_PermissionEvent(permissionEvent:BZNotifyMediaEvent)
Discussion
Call back to application with the result of a permission request. permissionEvent can have one of the following value:
- BZNotifyMediaEvent.NME_MICROPHONE_PERMISSION_GRANTED
- BZNotifyMediaEvent.NME_MICROPHONE_PERMISSION_DENIED
- BZNotifyMediaEvent.NME_SPEECHRECOGNIZER_PERMISSION_GRANTED
- BZNotifyMediaEvent.NME_SPEECHRECOGNIZER_PERMISSION_DENIED
Parameters
permissionEventThe result of the permission request.
Declared In
BZVoiceFlowCallback.swift
BZVFC_PlayAudioSegmentData
func BZVFC_PlayAudioSegmentData(vfModuleID: String, promptID:String, audioSegmentType:BZAudioSegmentType, audioFile: String?, textString: String?, textFile: String?)
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
BZVoiceFlowCallback.swift
BZVFC_PreModuleEnd
func BZVFC_PreModuleEnd(vfModuleID: String)
Discussion
Call back to application just before Voiceflow processing of a Voiceflow module ends.
Parameters
vfModuleIDThe Voice Flow module ID.
Declared In
BZVoiceFlowCallback.swift
BZVFC_PreModuleStart
func BZVFC_PreModuleStart(vfModuleID: String)
Discussion
Call back to application just before Voiceflow processing of a Voiceflow module starts.
Parameters
vfModuleIDThe Voice Flow module ID.
Declared In
BZVoiceFlowCallback.swift
BZVFC_SRHypothesis
func BZVFC_SRHypothesis(vfModuleID: String, srData: BZSRData)
Discussion
Call back to application with speech recognition data genrated by an SR Hypothesis.
Parameters
vfModuleIDThe Voice Flow module ID.
srDataThe speech recognition result data.
Declared In
BZVoiceFlowCallback.swift