Input Components
EstuaryMicrophone
MonoBehaviour -- Captures microphone audio and sends it to the server. In LiveKit mode the microphone is captured natively by WebRTC (with platform AEC); in WebSocket mode audio is captured via Unity's Microphone API and streamed as base64-encoded PCM16 over Socket.IO.
Namespace: Estuary
Inspector Fields
| Field | Type | Default | Description |
|---|---|---|---|
TargetCharacter | EstuaryCharacter | auto-found | The character to send audio to (auto-resolved from the same GameObject or its parents if blank) |
MicrophoneDevice | string | "" | Specific Unity microphone device name; empty selects the default. Used for WebSocket mode and LiveKit-mode VAD. |
note
Several settings (SampleRate, ChunkDurationMs, PushToTalkKey, UseVoiceActivityDetection, VadThreshold) exist as private fields with [SerializeField] attributes for advanced/internal use. They are not part of the supported public API and may change. Treat them as fixed defaults: 16 kHz, 100 ms chunks, no push-to-talk, VAD disabled.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
IsRecording | bool | get | true while the microphone is actively capturing (or unmuted in LiveKit mode) |
IsMuted | bool | get | true when muted |
IsLiveKitMode | bool | get | true when configured for LiveKit native capture |
CurrentVolume | float | get | Current audio volume level (0–1). VAD-derived in LiveKit mode. |
IsSpeechDetected | bool | get | true when local VAD detects speech |
SampleRate | int | get | Recording sample rate (read-only; WebSocket mode only) |
AvailableDevices | string[] | get | List of microphone device names from Microphone.devices |
TargetCharacter | EstuaryCharacter | get/set | Target character for audio streaming |
Methods
| Method | Returns | Description |
|---|---|---|
StartRecording() | void | Start capturing audio (LiveKit publishes the WebRTC mic; WebSocket starts Unity capture) |
StopRecording() | void | Stop capturing audio |
ToggleRecording() | void | Toggle recording on/off |
Mute() | void | Mute the microphone (LiveKit: mutes the WebRTC track; WebSocket: stops capture) |
Unmute() | void | Unmute the microphone |
SetMicrophoneDevice(string deviceName) | void | Change the WebSocket-mode microphone device (no-op in LiveKit mode) |
SetLiveKitManager(ILiveKitVoiceManager manager) | void | Switch to LiveKit native capture |
Configure(VoiceMode voiceMode, ILiveKitVoiceManager liveKitManager = null) | void | Configure the microphone for WebSocket or LiveKit mode |
Events
| Event | Signature | Description |
|---|---|---|
OnRecordingStarted | Action | Microphone started (or unmuted in LiveKit mode) |
OnRecordingStopped | Action | Microphone stopped (or muted in LiveKit mode) |
OnVolumeChanged | Action<float> | Volume level changed (0–1) |
OnSpeechDetected | Action | Local VAD detected speech |
OnSilenceDetected | Action | Local VAD detected silence after speech |
WebSocket vs LiveKit Behavior
| Behavior | WebSocket Mode | LiveKit Mode |
|---|---|---|
| Capture | Unity Microphone.Start() | Native WebRTC microphone source |
| Transport | Base64 PCM over Socket.IO | WebRTC audio track |
| AEC | None (server-side echo handling only) | Native platform AEC |
| Mute | Stops capturing | Mutes/restarts the WebRTC source |
| Server-side STT | Required (StartVoiceModeAsync) | Required (StartVoiceModeAsync) |
| Local VAD | Optional, used to gate sending audio | Optional, runs in parallel for client-side interrupts |