Made in Vancouver, Canada by Picovoice
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.
- iOS 13.0+
iOS Voice Processor is available via the Swift Package Manager and CocoaPods.
To import the package using SPM, open up your project's Package Dependencies in XCode and add:
https://github.com/Picovoice/ios-voice-processor.git
To import it into your iOS project using CocoaPods, add the following line to your Podfile:
pod 'ios-voice-processor'
To enable recording with your iOS device's microphone you must add the following to your app's Info.plist
file:
<key>NSMicrophoneUsageDescription</key>
<string>[Permission explanation]</string>
See our example app or this guide for how to properly request this permission from your users.
Access the singleton instance of VoiceProcessor
:
import ios_voice_processor
let voiceProcessor = VoiceProcessor.instance
Add listeners for audio frames and errors:
let frameListener = VoiceProcessorFrameListener { frame in
// use audio
}
let errorListener = VoiceProcessorErrorListener { error in
// handle error
}
voiceProcessor.addFrameListener(frameListener);
voiceProcessor.addErrorListener(errorListener);
Start audio capture with the desired frame length and audio sample rate:
do {
try voiceProcessor.start(frameLength: 512, sampleRate: 16000);
} catch {
// handle start error
}
Stop audio capture:
do {
try voiceProcessor.stop();
} catch {
}
Once audio capture has started successfully, any frame listeners assigned to the VoiceProcessor
will start receiving audio frames with the given frameLength
and sampleRate
.
Any number of listeners can be added to and removed from the VoiceProcessor
instance. However,
the instance can only record audio with a single audio configuration (frameLength
and sampleRate
),
which all listeners will receive once a call to start()
has been made. To add multiple listeners:
let listener1 = VoiceProcessorFrameListener({_ in })
let listener2 = VoiceProcessorFrameListener({_ in })
let listeners: [VoiceProcessorFrameListener] = [listener1, listener2];
voiceProcessor.addFrameListeners(listeners);
voiceProcessor.removeFrameListeners(listeners);
// or
voiceProcessor.clearFrameListeners();
The iOS Voice Processor app demonstrates how to ask for user permissions and capture output from the VoiceProcessor
.
- Add support for Swift Package Manager
- Bumped minimum iOS version to 13
- Numerous API improvements
- Error handling improvements
- Allow for multiple listeners instead of a single callback function
- Upgrades to testing infrastructure and example app
- Initial public release.