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

Instance Methods

STVFC_MediaEvent

func STVFC_MediaEvent

Discussion

Call back to application with media event notifications.

Parameters

vfModuleID

The Voice Flow module ID.

mediaItemID

The ID of the media item being processed for which this media event notification applies.

mediaFunction

The media function.

mediaEvent

The media event.

mediaEventData

The 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

permissionEvent

The 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

vfModuleID

The Voice Flow module ID.

promptID

The audio prompt module ID.

promptType

The audio segment type.

audioFile

The file name of the recorded audio file processed for audio playback.

textString

The text processed for audio playback.

textFile

The 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

vfModuleID

The Voice Flow module ID.

Declared In

STVoiceFlowCallback.swift

STVFC_PreModuleStart

func STVFC_PreModuleStart

Discussion

Call back to application just before Voiceflow processing of a Voiceflow module starts.

Parameters

vfModuleID

The Voice Flow module ID.

Declared In

STVoiceFlowCallback.swift

STVFC_SRHypothesis

func STVFC_SRHypothesis

Discussion

Call back to application with speech recognition data genrated by an SR Hypothesis.

Parameters

vfModuleID

The Voice Flow module ID.

srData

The speech recognition result data.

Declared In

STVoiceFlowCallback.swift