Voice Activity Detector
This guide will walk you through the steps to set up the Voice Detection project in Unity. Follow the instructions to clone the repository, set up the interface, and ensure everything is working correctly.
Table of Contents
Prerequisites
Unity installed
Git installed on your machine
Step 1: Clone the Repository
First, you need to clone the repository from GitHub to your local machine. Open your terminal or command prompt and run the following command:
Step 2: Open the Cloned Project
Second, you need to open the project you just cloned from github using Unity Editor:
To use the pre-existing scene, open
/Assets/Scenes and double click on the SampleScene file. This should be enough to open the project. (You are good to stop here).To create your own scene, open Unity editor, click on
Open Project and navigate to the directory where you cloned the Voice detection project and select the directoryStep 3: Setup the Interface
Create a UI Canvas:
In the Hierarchy window, right-click and select UI > Canvas. This will create a Canvas object in the scene.
Right-click on the Canvas in the Hierarchy and select UI > Panel. This panel will serve as the container for your UI elements.
Create the Microphone Icon:
Right-click on the Panel in the Hierarchy and select UI > Image.
Rename it MicrophoneIcon.
With the MicrophoneIcon selected, go to the Inspector and:
Set the
Source Image to the microphone-icon image from the /Assets/Icon directory.Adjust the
Rect Transform settings to achieve your desired positioning.Create the StatusText:
Right-click on the Panel in the Hierarchy and select UI > Text - TextMeshPro (If TextMeshPro is not available, you may need to install the TextMeshPro package via the Package Manager).
Rename this TextMeshPro object to "StatusText".
With the StatusText selected, go to the Inspector and:
Set the text properties such as Font Size, Alignment, Color, etc., as per your requirements.
Setup the Panel and Canvas Group:
Select the Panel in the Hierarchy.
In the Inspector, add a
CanvasGroup component by clicking on Add Component and searching for CanvasGroup.Adjust the
Rect Transform of the Panel to the desired size and position.Set the
Image component's color to your desired color.Create GameObjects:
Right-click on the Hierarchy >
Create Empty and rename the empty GameObject to VoiceDetectionUI. With the VoiceDetectionUI GameObject selected, in the Inspector click on Add Component, search and add the VoiceDetectionUI.cs script.Repeat the above step for
VADProcessor.cs and AudioCapture.cs scripts.Configure UI script:
With the VoiceDetectionUI GameObject selected, go to the Inspector where the VoiceDetectionUI script is attached.
Drag and drop the following objects into their respective fields in the Inspector:
MicrophoneIcon: Drag the Image object (MicrophoneIcon) here
StatusText: Drag the TextMeshPro object (StatusText) here.
Panel: Drag the Panel object here.
PanelCanvasGroup: Drag the CanvasGroup component of the Panel here.
VADProcessor: Drag the GameObject with the VADProcessor script attached here.
AudioCapture: Drag the GameObject with the AudioCapture script attached here.
Step 4: Run the Scene
Click on the play button on the Unity Editor.
You have successfully setup and run the project!
Tips
Resolving "VAD is not initialized!" Error
If you encounter the "VAD is not initialized!" error, follow these steps to resolve it:
Install NuGet in Unity:
Download the
NuGetForUnity.unitypackage file from https://github.com/GlitchEnzo/NuGetForUnity/releasesIn the Unity Editor, go to Assets > Import Package > Custom Package....
Select the
NuGetForUnity.unitypackage file you downloaded and click Open.In the import window, ensure all items are selected and click Import.
Install WebRtcVadSharp using
.nupkg:Download the webrtcvadsharp.1.3.2.nupkg file from
https://www.nuget.org/packages/WebRtcVadSharpIn Unity, go to NuGet > Manage NuGet Packages.
Click on the + button and select Install from File....
Navigate to the
webrtcvadsharp.1.3.2.nupkg file you downloaded and click Open.Download WebRtcVad.dll
Open the following link in your browser,
https://www.nuget.org/packages/WebRtcVadSharpClick on the Open in NuGet Package Explorer link.
In NuGet Package Explorer, navigate to the
/build/-x64/native directory and double-click on WebRtcVad.dll to download it.Copy WebRtcVad.dll
Copy the downloaded
WebRtcVad.dll file.Paste it into the
/Assets/Packages/WebRtcVadSharp.1.3.2/lib/netstandard2.0 directory in your Unity project.Refresh the project in Unity Editor by right-clicking in the Project window and selecting Refresh.
Run the Project Again:
After completing the above steps, run your project again in Unity. The VAD should now be properly initialized.
Contibuting
We welcome contributions to the Voice Activity Detector project. To contribute:
Fork the repository
Create a new branch for your feature or bugfix.
Make your changes an commit them.
Push your branch to your forked repository.
Open a pull request to the main repository.
License
N/A.
Acknowledgments
Special thanks to the following libraries and frameworks and package managers used in this project:
Unity: The primary game development platform used to build and run the project.
TextMeshPro: For providing advanced text rendering in Unity.
WebRtcVadSharp: For enabling voice activity detection in the project.
Git: For version control and collaboration.
GitHub: For hosting the project repository and facilitating collaboration.
1 like · 21 views · Jul 26, 2025
Real-time voice activity detection in Unity: streams microphone audio and flags speech frame-by-frame with the WebRTC VAD, plus a live on-screen indicator.