Class AutoStartStopAudioSource

ru.yandex.speechkit

java.lang.Object ⇽ AutoStartStopAudioSource

public  class  AutoStartStopAudioSource 

An audio source that automatically starts and stops audio recording using the standard device input.

Reading of the audio from the device input starts automatically as soon as the first listener is subscribed and stops when all listeners unsubscribe.

The class is thread-safe, i.e., it can be accessed from different threads. An object of the AutoStartStopAudioSource class is reusable, it can start and stop the audio recording process unlimited number of times. A listener just needs to subscribe to it again.

If the app has the "android.permission.RECORD_AUDIO", the audio source will start and begin giving data to listeners. If the app does not have such permission, the audio source will send the listeners an error with the ERROR_AUDIO_PERMISSIONS code in the onAudioSourceError (AudioSource, Error) method.

Nested Classes

Methods

voidunsubscribe(@NonNull final AudioSourceListener listener)

This method unsubscribes the listener that implements the AudioSourceListener interface.

Method Detail

unsubscribe

public void unsubscribe (@NonNull final AudioSourceListener listener)

This method unsubscribes the listener that implements the AudioSourceListener interface.

Parameters:
listener

A listener that receives audio data and messages about the status of an audio source.