Neocortex
IntegrationsUnity SDKAPI Reference

Neocortex Audio Receiver

One microphone component for every platform

NeocortexAudioReceiver is the microphone. Add it anywhere in the scene and voice input works on desktop, mobile and WebGL. It spawns the right capture backend for the target platform internally, handles the Android and iOS permission prompt, and owns microphone selection, so your game never touches the platform layers.

Neocortex Audio Receiver component

Anything that takes an AudioReceiver, such as NeocortexAudioChatInput, accepts it directly.

You often do not add it yourself. Picking an audio Chat Lines Mode on a Smart Agent adds one if the scene has no microphone yet, and with Auto Voice Input on the agent records and answers through it without any wiring. Add it by hand when you want to drive recording yourself.

Inspector

FieldDescription
Use Push To TalkHold a button to record instead of listening for speech. Switchable at runtime.
Amplitude ThresholdHow loud speech must be to start recording, in voice activity mode.
Max Wait TimeStop automatically after this long without sound.
Request Permission On StartAsk for microphone permission as the component starts, instead of on the first recording.

It shows you what it hears

In Play Mode the inspector turns into a live readout: the current state (Waiting User Input, Recording or Busy), the input level with a marker at the speech threshold, and the silence timeout draining to zero. A scene with no chat UI is still readable.

Audio Receiver live readout

Methods

StartMicrophone

Begin listening. Waits for permission first, and raises OnRecordingFailed if it is denied.

StartMicrophone Example
var mic = GetComponent<NeocortexAudioReceiver>();
var agent = GetComponent<NeocortexSmartAgent>();

mic.OnAudioRecorded.AddListener((clip) => agent.AudioToAudio(clip));
mic.StartMicrophone();

StopMicrophone

Stop listening. In voice activity mode the clip is cut and OnAudioRecorded is raised.

StopMicrophone Example
mic.StopMicrophone();

SelectMicrophone

Picks an input device by its index in Microphones. The selection is remembered between sessions and can be changed while the game is running. NeocortexMicrophoneDropdown is a ready made picker for this.

  • Parameters:
    • index: Index of the device in the Microphones array.
    SelectMicrophone Example
    string[] devices = mic.Microphones;
    mic.SelectMicrophone(1);
    Debug.Log($"Recording with {devices[mic.SelectedMicrophoneIndex]}");

SetPushToTalk

Switches between voice activity and push to talk at runtime, so you can offer it as a settings toggle. In voice activity mode the microphone listens continuously and cuts a clip when speech starts and stops. In push to talk it records only while the button is held.

  • Parameters:
    • enabled: true for push to talk, false for voice activity.
    SetPushToTalk Example
    mic.SetPushToTalk(true); // same as mic.usePushToTalk = true

SetCustomReceiver

Swaps in a different capture implementation, for a test feed or a third party microphone stack. It replaces and destroys the spawned platform backend.

  • Parameters:
    • custom: Your own AudioReceiver.

Events

OnAudioRecorded

Raised when a recording finishes.

  • Arguments:
    • audioClip: The recorded clip, ready to send to an agent.
    OnAudioRecorded Example
    mic.OnAudioRecorded.AddListener((clip) => agent.AudioToText(clip));

OnRecordingFailed

Raised when recording could not start.

  • Arguments:
    • error: The reason, for example a denied permission or no available device.
    OnRecordingFailed Example
    mic.OnRecordingFailed.AddListener((error) => Debug.LogWarning(error));

OnPermissionGranted

Raised when microphone permission is granted, on the platforms that ask.

OnPermissionGranted Example
mic.OnPermissionGranted.AddListener(() => recordButton.interactable = true);

OnPermissionDenied

Raised when microphone permission is refused. Use it to fall back to text input.

OnPermissionDenied Example
mic.OnPermissionDenied.AddListener(() => ShowTextOnlyChat());

For your own UI, IsListening, IsUserSpeaking and Amplitude expose the live state the inspector readout draws from, and Microphones lists the available devices.

Platform notes

PlatformBehaviour
DesktopRecords directly, no permission prompt.
Android and iOSThe permission prompt is handled for you, surfaced through the permission events.
WebGLThe browser owns the microphone and prompts on its own. The Neocortex WebGL template is required, see Sample Projects.

On this page