Protocol YSKAudioSource

The protocol for the audio source.

Used by speech recognition classes: YSKRecognizing and YSKPhraseSpotter. Any audio source can be used, such as standard device input, remote source, and so on.

Use of any audio source works as follows:

  • Creating and starting an object that provides sound data. When an audio source is ready to transmit data to listeners, it should send a message to each subscribed listener using the audioSourceDidStart: method. If a new listener subscribes while the audio source is running, it also receives a message upon subscription (via the audioSourceDidStart: method).

  • Transmitting data to listeners by fragments at a certain interval. Data is transmitted using the audioSource:didReceiveData: method. The interval is set via the value of the bufferCaptureTimeout property. Listeners can request these values before subscribing to an audio source.

  • Upon completion of the audio source operation, listeners should be notified of that via the audioSourceDidStop: method. At the time when the audio source stops, the number of listeners may decrease, as they may unsubscribe in the process of its operation. For example, YSKOnlineRecognizer unsubscribes when the end of speech is detected.

If the audio source uses the standard device input, you should configure the app's audio session correctly. The YSKAudioSessionHandler class makes the setup of audio sessions easier: if your app uses the audio session only when working with the SpeechKit library, it is recommended to use this class to configure the audio session.
  • If your app uses the audio session outside the library (for audio and video playback, audio recording, and so on), you can also use this class or configure the audio session independently. In your own class that implements the YSKAudioSource protocol, ask the user for access to audio recording. For that, call the -[AVAudioSession requestRecordPermission:] system class method.

To enable YSKBaseAudioSource and its inheritors, YSKAutoAudioSource and YSKManualAudioSource, configure the audio session. Unless set up properly, they will return an error with the YSKErrorAudioRecording code in the audioSource:didFailWithError: method. Possible error codes are listed in YSKErrorCode.

Instance Methods

-subscribeListener:

This method subscribes a listener that implements the YSKAudioSourceListener protocol.

-unsubscribeListener:

This method unsubscribes the listener that implements the YSKAudioSourceListener protocol.

Properties

audioProcessingMode

Information on whether the audio source performs additional processing of the audio.

bufferCaptureTimeout

The interval between the audio fragments that the audio source sends to the listeners.

soundInfo

Information on the audio that will be transmitted by this audio source.

Method Detail

-subscribeListener:

- (void)subscribeListener:(id< YSKAudioSourceListener >)listener 

This method subscribes a listener that implements the YSKAudioSourceListener protocol.

Parameters:
listener

A listener that will receive messages on the audio source status and audio data.

-unsubscribeListener:

- (void)unsubscribeListener:(id< YSKAudioSourceListener >)listener 

This method unsubscribes the listener that implements the YSKAudioSourceListener protocol.

Parameters:
listener

A listener that will receive messages on the audio source status and audio data.

Property Detail

audioProcessingMode

(copy, readonly) YSKAudioProcessingMode * audioProcessingMode

Information on whether the audio source performs additional processing of the audio.

If the audio source converts the incoming audio signal either by using the AEC algorithm or by skipping some of the sounds, it should pass the appropriate value. Otherwise, the property can be omitted. Default value: pass.

bufferCaptureTimeout

(assign, readonly) NSTimeInterval bufferCaptureTimeout

The interval between the audio fragments that the audio source sends to the listeners.

soundInfo

(strong, readonly) YSKSoundInfo * soundInfo

Information on the audio that will be transmitted by this audio source.