Skip to main content

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

FieldTypeDefaultDescription
TargetCharacterEstuaryCharacterauto-foundThe character to send audio to (auto-resolved from the same GameObject or its parents if blank)
MicrophoneDevicestring""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

PropertyTypeAccessDescription
IsRecordingboolgettrue while the microphone is actively capturing (or unmuted in LiveKit mode)
IsMutedboolgettrue when muted
IsLiveKitModeboolgettrue when configured for LiveKit native capture
CurrentVolumefloatgetCurrent audio volume level (0–1). VAD-derived in LiveKit mode.
IsSpeechDetectedboolgettrue when local VAD detects speech
SampleRateintgetRecording sample rate (read-only; WebSocket mode only)
AvailableDevicesstring[]getList of microphone device names from Microphone.devices
TargetCharacterEstuaryCharacterget/setTarget character for audio streaming

Methods

MethodReturnsDescription
StartRecording()voidStart capturing audio (LiveKit publishes the WebRTC mic; WebSocket starts Unity capture)
StopRecording()voidStop capturing audio
ToggleRecording()voidToggle recording on/off
Mute()voidMute the microphone (LiveKit: mutes the WebRTC track; WebSocket: stops capture)
Unmute()voidUnmute the microphone
SetMicrophoneDevice(string deviceName)voidChange the WebSocket-mode microphone device (no-op in LiveKit mode)
SetLiveKitManager(ILiveKitVoiceManager manager)voidSwitch to LiveKit native capture
Configure(VoiceMode voiceMode, ILiveKitVoiceManager liveKitManager = null)voidConfigure the microphone for WebSocket or LiveKit mode

Events

EventSignatureDescription
OnRecordingStartedActionMicrophone started (or unmuted in LiveKit mode)
OnRecordingStoppedActionMicrophone stopped (or muted in LiveKit mode)
OnVolumeChangedAction<float>Volume level changed (0–1)
OnSpeechDetectedActionLocal VAD detected speech
OnSilenceDetectedActionLocal VAD detected silence after speech

WebSocket vs LiveKit Behavior

BehaviorWebSocket ModeLiveKit Mode
CaptureUnity Microphone.Start()Native WebRTC microphone source
TransportBase64 PCM over Socket.IOWebRTC audio track
AECNone (server-side echo handling only)Native platform AEC
MuteStops capturingMutes/restarts the WebRTC source
Server-side STTRequired (StartVoiceModeAsync)Required (StartVoiceModeAsync)
Local VADOptional, used to gate sending audioOptional, runs in parallel for client-side interrupts