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 in WebSocket mode. |
note
SampleRate and ChunkDurationMs are private Inspector settings for WebSocket capture. Their defaults are 16 kHz and 100 ms.
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) in WebSocket mode; LiveKit audio is captured separately. |
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 |
PushToTalkKey | KeyCode | get/set | Optional key held to talk while PTT is enabled (None = no key binding). Ignored when PTT is off. |
PushToTalkEnabled | bool | get/set | Turns PTT on or off; without a key, drive PushToTalkPress()/PushToTalkRelease() from your own input. |
IsPushToTalkMode | bool | get | Whether push-to-talk is enabled. |
IsPushToTalkHeld | bool | get | Whether the talk button is currently held. |
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 |
PushToTalkPress() | void | Signal a talk-button press — interrupts in-flight bot speech and opens the mic (requires an active voice session). |
PushToTalkRelease() | void | Signal a talk-button release — closes the mic and dispatches the turn to the server. |
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> | WebSocket microphone volume level changed (0–1) |
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) |
| Speech detection | Server-side | Server-side |