Voice Processor
iOS API
API Reference for the Voice Processor iOS SDK(CocoaPods).
VoiceProcessor
The iOS Voice Processor is an asynchronous audio capture library designed for real-time audio processing. Given some specifications, the library delivers frames of raw audio data to the user via listeners.
VoiceProcessor.instance
Singleton instance of VoiceProcessor
.
VoiceProcessor.isRecording
A boolean value indicating if the VoiceProcessor
is currently recording audio.
VoiceProcessor.frameLength
The number of audio samples per frame. Set when calling the start()
method.
VoiceProcessor.sampleRate
The sample rate for audio recording, set when calling the start()
method.
VoiceProcessor.numFrameListeners
The number of registered VoiceProcessorFrameListeners
.
VoiceProcessor.numErrorListeners
The number of registered VoiceProcessorErrorListeners
.
VoiceProcessor.hasRecordAudioPermission
Indicates whether the app has permission to record audio.
Returns
- Bool: True if the app has permission to record audio, false otherwise.
VoiceProcessor.requestRecordAudioPermission()
Requests permission to record audio from the user.
Parameters
response
@escaping (Bool) -> Void : A closure to handle the user's response to the permission request.
VoiceProcessor.addFrameListener()
Adds a listener to receive audio frames.
Parameters
listener
VoiceProcessorFrameListener: TheVoiceProcessorFrameListener
to be added as a frame listener.
VoiceProcessor.addFrameListeners()
Adds multiple frame listeners to receive audio frames.
Parameters
listeners
[VoiceProcessorFrameListener] : An array ofVoiceProcessorFrameListener
to be added as frame listeners.
VoiceProcessor.removeFrameListener()
Removes a previously added frame listener.
Parameters
listener
VoiceProcessorFrameListener : TheVoiceProcessorFrameListener
to be removed.
VoiceProcessor.removeFrameListeners()
Removes previously added multiple frame listeners.
Parameters
listeners
[VoiceProcessorFrameListener] : An array ofVoiceProcessorFrameListener
to be removed.
VoiceProcessor.clearFrameListeners()
Clears all currently registered frame listeners.
VoiceProcessor.addErrorListener()
Adds an error listener.
Parameters
listener
VoiceProcessorErrorListener : TheVoiceProcessorErrorListener
to be added as an error listener.
VoiceProcessor.removeErrorListener()
Removes a previously added error listener.
Parameters
listener
VoiceProcessorErrorListener : TheVoiceProcessorErrorListener
to be removed.
VoiceProcessor.clearErrorListeners()
Clears all error listeners.
VoiceProcessor.start()
Starts audio recording with the specified audio properties.
Parameters
frameLength
UInt32 : The length of each audio frame, in number of samples.sampleRate
UInt32 : The sample rate to record audio at, in Hz.
Throws
VoiceProcessorError
: An error if there is an issue starting the audio recording.
VoiceProcessor.stop()
Stops audio recording and releases audio resources.
Throws
VoiceProcessorError
: An error if there is an issue stopping the audio recording.
VoiceProcessorError
Error thrown if an error occurs within the VoiceProcessor
.
VoiceProcessorErrorCallback
Typealias for the callback function that handles errors that are emitted from VoiceProcessor
.
VoiceProcessorErrorListener
Listener class for receiving errors from VoiceProcessor
.
VoiceProcessorErrorListener.init()
Initializes a new VoiceProcessorErrorListener
.
Parameters
callback
@escaping VoiceProcessorErrorCallback : The callback function to be called when aVoiceProcessorError
occurs.
VoiceProcessorErrorListener.onError()
Function called when a VoiceProcessorError
occurs.
Parameters
error
VoiceProcessorError : Error.
VoiceProcessorFrameCallback
Typealias for the callback function that handles frames of audio data.
VoiceProcessorFrameListener
Listener class for receiving audio frames from VoiceProcessor
.
VoiceProcessorFrameListener.init()
Initializes a new VoiceProcessorFrameListener
.
Parameters
callback
@escaping VoiceProcessorFrameCallback : The callback function to be called when an audio frame is received.
VoiceProcessorFrameListener.onFrame()
Function called when a frame of audio is received.
Parameters
frame
[Int16] : Frame of audio.