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 in WebSocket mode.
note

SampleRate and ChunkDurationMs are private Inspector settings for WebSocket capture. Their defaults are 16 kHz and 100 ms.

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) in WebSocket mode; LiveKit audio is captured separately.
SampleRateintgetRecording sample rate (read-only; WebSocket mode only)
AvailableDevicesstring[]getList of microphone device names from Microphone.devices
TargetCharacterEstuaryCharacterget/setTarget character for audio streaming
PushToTalkKeyKeyCodeget/setOptional key held to talk while PTT is enabled (None = no key binding). Ignored when PTT is off.
PushToTalkEnabledboolget/setTurns PTT on or off; without a key, drive PushToTalkPress()/PushToTalkRelease() from your own input.
IsPushToTalkModeboolgetWhether push-to-talk is enabled.
IsPushToTalkHeldboolgetWhether the talk button is currently held.

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
PushToTalkPress()voidSignal a talk-button press — interrupts in-flight bot speech and opens the mic (requires an active voice session).
PushToTalkRelease()voidSignal a talk-button release — closes the mic and dispatches the turn to the server.

Events​

EventSignatureDescription
OnRecordingStartedActionMicrophone started (or unmuted in LiveKit mode)
OnRecordingStoppedActionMicrophone stopped (or muted in LiveKit mode)
OnVolumeChangedAction<float>WebSocket microphone volume level changed (0–1)

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)
Speech detectionServer-sideServer-side