EstuaryMicrophone
MonoBehaviour -- Captures microphone audio and sends it to the server. Supports both WebSocket (Unity Microphone API) and LiveKit (WebRTC RtcAudioSource) modes.
Namespace: Estuary
Inspector Fields
| Field | Type | Default | Description |
|---|
SampleRate | int | 16000 | Recording sample rate in Hz |
ChunkDurationMs | int | 100 | Audio chunk size in milliseconds |
PushToTalkKey | KeyCode | None | Key for push-to-talk. None = always-on |
UseVoiceActivityDetection | bool | false | Enable client-side VAD (WebSocket mode) |
VadThreshold | float | 0.5 | VAD sensitivity: 0 = most sensitive, 1 = least sensitive |
Properties
| Property | Type | Access | Description |
|---|
IsRecording | bool | get | true while the microphone is capturing |
IsMuted | bool | get | true when muted (LiveKit mode) |
CurrentVolume | float | get | Current audio volume level (0--1) |
IsSpeechDetected | bool | get | true when VAD detects speech |
Methods
| Method | Returns | Description |
|---|
StartRecording() | void | Start capturing audio |
StopRecording() | void | Stop capturing audio |
Configure(int sampleRate, int chunkDurationMs) | void | Reconfigure audio settings |
Mute() | void | Mute the microphone (LiveKit: mutes the track) |
Unmute() | void | Unmute the microphone |
Events
| Event | Signature | Description |
|---|
OnRecordingStarted | Action | Microphone started capturing |
OnRecordingStopped | Action | Microphone stopped capturing |
OnVolumeChanged | Action<float> | Volume level changed (0--1) |
OnSpeechDetected | Action | User started speaking (VAD) |
OnSilenceDetected | Action | User stopped speaking (VAD) |
WebSocket vs LiveKit Behavior
| Behavior | WebSocket Mode | LiveKit Mode |
|---|
| Capture | Unity Microphone.Start() | LiveKit RtcAudioSource |
| Transport | Base64 PCM over Socket.IO | WebRTC audio track |
| AEC | None (manual echo handling) | Native platform AEC |
| Mute | Stops sending chunks | Mutes the WebRTC track |
| VAD | Client-side amplitude check | Server-side; client VAD used for interrupt detection |
Push-to-Talk
When PushToTalkKey is set to a key other than None:
- WebSocket mode: Audio is only captured and sent while the key is held
- LiveKit mode: The microphone track is muted when the key is released and unmuted when pressed