Voice Processor
Android API
API Reference for the Voice Processor Android SDK(android-voice-processor).
package: ai.picovoice.android.voiceprocessor
VoiceProcessor
Class for capturing audio and delivering audio data via listeners.
VoiceProcessor.getInstance()
Obtain singleton instance of the VoiceProcessor
.
Returns
VoiceProcessor
: Singleton instance.
VoiceProcessor.getIsRecording()
Indicates whether the VoiceProcessor
is currently recording or not.
Returns
- boolean : flag indicating whether the
VoiceProcessor
is currently recording.
VoiceProcessor.hasRecordAudioPermission()
Indicates whether the given context has been granted RECORD_AUDIO
permissions or not.
Parameters
context
Context : Android app context.
Returns
- boolean : flag indicating whether
RECORD_AUDIO
permission has been granted.
VoiceProcessor.addFrameListener()
Add a frame listener that will receive audio frames generated by the VoiceProcessor
.
Parameters
listener
VoiceProcessorFrameListener : listener for processing frames of audio.
VoiceProcessor.addFrameListeners()
Add multiple frame listeners that will receive audio frames generated by the VoiceProcessor
.
Parameters
listeners
VoiceProcessorFrameListener[] : listeners for processing frames of audio.
VoiceProcessor.removeFrameListener()
Remove a frame listener from the VoiceProcessor
. It will no longer receive audio frames.
Parameters
listener
VoiceProcessorFrameListener : listener to remove
VoiceProcessor.removeFrameListeners()
Remove frame listeners from the VoiceProcessor
. They will no longer receive audio frames.
Parameters
listener
VoiceProcessorFrameListener[] : listeners to remove
VoiceProcessor.clearFrameListeners()
Clear all frame listeners from the VoiceProcessor. They will no longer receive audio frames.
VoiceProcessor.getNumFrameListeners()
Get number of frame listeners that are currently subscribed to the VoiceProcessor.
Returns
- int : the number of frame listeners
VoiceProcessor.addErrorListener()
Add an error listener that will receive errors generated by the VoiceProcessor
.
Parameters
errorListener
VoiceProcessorErrorListener : listener for catching recording errors.
VoiceProcessor.removeErrorListener()
Remove an error listener from the VoiceProcessor
that had previously been added.
Parameters
errorListener
VoiceProcessorErrorListener : error listener to remove.
VoiceProcessor.clearErrorListeners()
Clear all error listeners from the VoiceProcessor
.
VoiceProcessor.getNumErrorListeners()
Get number of error listeners that are currently subscribed to the VoiceProcessor
.
Returns
- int : the number of error listeners
VoiceProcessor.start()
Starts audio capture. You need to subscribe a VoiceProcessorFrameListener via addFrameListner()
in order to receive audio frames from the VoiceProcessor
.
Parameters
requestedFrameLength
int : Number of audio samples per frame.requestedSampleRate
int : Audio sample rate that the audio will be captured with.
Throws
VoiceProcessorArgumentException
: error ifVoiceProcessor
is already recording with a different configuration.
VoiceProcessor.stop()
Stops audio capture. Frames will stop being delivered to the subscribed listeners.
Throws
VoiceProcessorException
: if an error is encountered while trying to stop the recorder thread.
VoiceProcessorFrameListener
Listener type that can be added to VoiceProcessor with addFrameListener()
. Captures audio frames that are generated by the recording thread.
VoiceProcessorErrorListener
Listener type that can be added to VoiceProcessor with addErrorListener()
. Captures errors that are thrown by the recording thread.
VoiceProcessorException
Exception thrown if an error occurs within the VoiceProcessor
.
Exceptions: