ios-voice-processor 1.2.0

ios-voice-processor 1.2.0

Maintained by Kwangsoo Yeo, Ian Lavery, David Bartle, Mohammadreza Rostam.



  • By
  • Picovoice

iOS Voice Processor

GitHub release GitHub

Cocoapods

Made in Vancouver, Canada by Picovoice

Twitter URL

YouTube Channel Views

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.

Table of Contents

Requirements

Compatibility

  • iOS 11.0+

Installation

iOS Voice Processor is available via CocoaPods. To import it into your iOS project, add the following line to your Podfile:

pod 'ios-voice-processor'

Permissions

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.

Usage

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.

Capturing with Multiple Listeners

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();

Example

The iOS Voice Processor app demonstrates how to ask for user permissions and capture output from the VoiceProcessor.

Releases

v1.1.0 - July 31, 2023

  • Numerous API improvements
  • Error handling improvements
  • Allow for multiple listeners instead of a single callback function
  • Upgrades to testing infrastructure and example app

v1.0.0 - August 5, 2021

  • Initial public release.