https://github.com/picovoice/unity-voice-processor
Unity audio recording package designed for real-time speech audio processing
https://github.com/picovoice/unity-voice-processor
android audio audio-processing audio-recorder csharp ios linux macos unity windows
Last synced: about 1 year ago
JSON representation
Unity audio recording package designed for real-time speech audio processing
- Host: GitHub
- URL: https://github.com/picovoice/unity-voice-processor
- Owner: Picovoice
- License: apache-2.0
- Created: 2021-01-15T22:06:49.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-08-25T23:43:59.000Z (almost 3 years ago)
- Last Synced: 2025-03-29T08:51:06.319Z (about 1 year ago)
- Topics: android, audio, audio-processing, audio-recorder, csharp, ios, linux, macos, unity, windows
- Language: C#
- Homepage:
- Size: 172 KB
- Stars: 8
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Unity Voice Processor
[](https://github.com/Picovoice/unity-voice-processor/releases)
[](https://github.com/Picovoice/unity-voice-processor/)
Made in Vancouver, Canada by [Picovoice](https://picovoice.ai)
[](https://twitter.com/AiPicovoice)
[](https://www.youtube.com/channel/UCAdi9sTCXLosG1XeqDwLx7w)
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
- [Unity Voice Processor](#unity-voice-processor)
- [Table of Contents](#table-of-contents)
- [Compatibility](#compatibility)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Capturing with Multiple Listeners](#capturing-with-multiple-listeners)
- [Demo](#demo)
## Compatibility
[`Unity Voice Processor` package](./unity-voice-processor-1.0.0.unitypackage) 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)
## Requirements
- Unity 2017.4+
- Unity Build Support modules for desired platforms
## Installation
The easiest way to install the `Unity Voice Processor` is to import [unity-voice-processor-1.0.0.unitypackage](./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`:
```csharp
using Pv.Unity;
VoiceProcessor voiceProcessor = VoiceProcessor.Instance;
```
Create and add listeners for audio frames:
```csharp
void onFrameCaptured(short[] frame) {
// use audio data
}
voiceProcessor.AddFrameListener(onFrameCaptured);
```
Start audio capture with the desired frame length and audio sample rate:
```csharp
readonly int frameLength = 512;
readonly int sampleRate = 16000;
voiceProcessor.StartRecording(frameLength, sampleRate);
```
Stop audio capture:
```csharp
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:
```csharp
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](./Assets/UnityVoiceProcessor/Demo/) demonstrates how to ask for user permissions and capture output from
the `Unity Voice Processor`.