Unity integration library for Azure AI VoiceLive API. Enables real-time voice conversations with AI models (GPT-4o, etc.) and custom AI agents in Unity applications.
This library provides a wrapper to easily use the Microsoft Foundry VoiceLive API from Unity. It abstracts complex processes such as WebSocket communication, audio capture/playback, and avatar video streaming, providing them as Inspector-configurable components.
- Real-time Voice Conversations: Voice interactions with Azure AI models (GPT-4o) and custom agents
- Unity Components: MonoBehaviour-based components configurable via Inspector
- WebSocket Integration: Efficient WebSocket communication with main thread event handling
- Audio Processing: Microphone input capture and AudioSource playback (PCM16 format)
- Avatar Support: Avatar video streaming via Unity WebRTC (optional)
- Unity 6000.0 or later
- .NET Standard 2.1
- Microsoft Foundry account with VoiceLive API access
com.unity.webrtc3.0.0 or later (required for avatar features)
- Open Unity Package Manager (Window → Package Manager)
- Click "+" button → "Add package from git URL"
- Enter one of the following URLs:
Latest version (upm branch):
https://github.com/TakahiroMiyaura/UnityVoiceLiveAPI.git#upm
Specific version (e.g., 1.0.0):
https://github.com/TakahiroMiyaura/UnityVoiceLiveAPI.git#upm@1.0.0
- Clone or download this repository
- Copy the
Unity/UnityVoiceLiveAPI/Assets/Reseul/UnityVoiceLiveAPIfolder to your Unity project'sPackagesdirectory - Ensure required dependencies are installed:
com.unity.nuget.newtonsoft-json(3.2.1 or later)
- Create an empty GameObject in your scene
- Attach the
UnityVoiceLiveClientcomponent - Configure connection settings in the Inspector:
- Endpoint: Azure AI endpoint URL
- Access Token: API key or Bearer token
- Connection Mode: Select AIAgent or AIModel
To use a specific microphone device (e.g., XR headset microphone):
- Create an audio capture settings asset:
- Right-click in Project window
- Select Create > VoiceLive API > Audio Capture > Unity Microphone
- Configure the device name and other settings in the Inspector
- Assign the asset to Audio Capture Settings field in
UnityVoiceLiveClient
If not configured, the default system microphone will be used.
using Com.Reseul.Azure.AI.VoiceLiveAPI.Unity.Components;
using UnityEngine;
public class VoiceExample : MonoBehaviour
{
private UnityVoiceLiveClient client;
void Start()
{
client = GetComponent<UnityVoiceLiveClient>();
// Setup event listeners
client.OnSessionStarted.AddListener(() =>
{
Debug.Log("Session started!");
});
client.OnTranscriptReceived.AddListener((transcript) =>
{
Debug.Log($"Transcript: {transcript}");
});
// Start connection
_ = client.Connect();
}
}The package includes the following samples:
A sample demonstrating voice conversations with avatar video streaming.
How to import:
- Select this package in Unity Package Manager
- Import "Avatar Sample" from the "Samples" section
Unity MonoBehaviour Components
↓
UnityVoiceLiveClient (Main Thread Queue)
↓
VoiceLive API Core (.NET Standard 2.1)
↓
Microsoft Foundry WebSocket API
| Platform | Support | Notes |
|---|---|---|
| Windows (Standalone) | ✅ | |
| Android | ✅ | Microphone permissions required |
For detailed documentation, see:
- Package README - Detailed usage and API reference
- CHANGELOG - Release notes
- THIRD-PARTY-NOTICES - Third-party licenses
Takahiro Miyaura
- GitHub: @TakahiroMiyaura
Issues and Pull Requests are welcome. See CONTRIBUTING.md for details.