Made in Vancouver, Canada by Picovoice
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.
Unity Voice Processor
package unity package is for on Unity 2017.4+ on the following platforms:
- Android 5.0+ (API 21+) (ARM only)
- iOS 11.0+
- Windows (x86_64)
- macOS (x86_64, arm64)
- Linux (x86_64)
- Unity 2017.4+
- Unity Build Support modules for desired platforms
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...
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
.
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();
The Unity Voice Processor Demo demonstrates how to ask for user permissions and capture output from
the Unity Voice Processor
.