Home

Awesome

Unity Voice Processor

GitHub release GitHub

Made in Vancouver, Canada by Picovoice

<!-- markdown-link-check-disable -->

Twitter URL

<!-- markdown-link-check-enable -->

YouTube Channel Views

The Unity 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

Compatibility

Unity Voice Processor package unity package is for on Unity 2017.4+ on the following platforms:

Requirements

Installation

The easiest way to install the Unity Voice Processor is to import unity-voice-processor-1.0.0.unitypackage into your Unity projects by either dropping it into the Unity editor or going to Assets>Import Package>Custom Package...

Usage

Access the singleton instance of VoiceProcessor:

using Pv.Unity;

VoiceProcessor voiceProcessor = VoiceProcessor.Instance;

Create and add listeners for audio frames:

void onFrameCaptured(short[] frame) {
    // use audio data
}

voiceProcessor.AddFrameListener(onFrameCaptured);

Start audio capture with the desired frame length and audio sample rate:

readonly int frameLength = 512;
readonly int sampleRate = 16000;

voiceProcessor.StartRecording(frameLength, sampleRate);

Stop audio capture:

voiceProcessor.StopRecording();

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:

void OnFrameCaptured1(short[] frame) { }
void OnFrameCaptured2(short[] frame) { }

VoiceProcessorFrameListener[] listeners = new VoiceProcessorFrameListener[] {
        OnFrameCaptured1, OnFrameCaptured2 
};

voiceProcessor.AddFrameListeners(listeners);

voiceProcessor.RemoveFrameListeners(listeners);
// or
voiceProcessor.ClearFrameListeners();

Demo

The Unity Voice Processor Demo demonstrates how to ask for user permissions and capture output from the Unity Voice Processor.