Skip to main content

AudioCapture

Module: Inworld.AI. Namespace: Inworld.

This is a global audio capture controller. For each individual InworldCharacter, we use the AudioInteraction class to handle AudioClips.

Inspector Variables

VariableDescription
SamplingModeThe current Sampling Mode.
PlayerVolumeThreadThe volume multiplier used to determine whether the player is speaking.
Buffer SecondsSpecifies the duration, in seconds, for recording and generating a sample to be sent to the server.
Device NameThe name of the current sampling device.

Events

EventDescription
OnRecordingStartTriggered when the microphone begins sampling.
OnRecordingEndTriggered when the microphone stops sampling.
OnPlayerStartSpeakingTriggered when the player starts speaking.
NOTE: It might not be very accurate based on the background noices.
OnPlayerStopSpeakingTriggered when the player stops speaking.
NOTE: It might not be very accurate based on the background noices.

Properties

PropertyDescription
CurrentPlayingAudioSourceGets/Sets the current playing audio source.
VolumeGets the global setting of the volumes (From 0 to 1).
IsBlockedIndicates if audio is currently blocked from being captured.
IsCapturingIndicates if the microphone is currently capturing audio.
AutoPushIndicates if audio should be automatically pushed to the server as it is captured.
SampleModeThe Sampling Mode used by the Microphone. Determines how audio input is handled and processed for interactions.
IsPlayerTurnA flag to check if player is allowed to speak and without filtering.
IsAudioAvailableA flag to check if audio is available to send to server.
(Either Enable AEC or it's Player's turn to speak)
IsPlayerSpeakingIndicates if the user is speaking based on audio amplitude and threshold.
BackgroundNoiseGet the background noises, including music.
DeviceNameGets the audio input device name for recording.
DevicesGets the list of the AudioDevice.
EnableAECGets if acoustic echo cancellation (AEC) is enabled. By default, this is set to false in the parent class.

API

FunctionDescriptionParameters
ChangeInputDeviceChanges the microphone input device.deviceName: The name of the input device.
StartRecordingInitiates recording using Unity's official microphone module, triggering the OnRecordingStart event.
StopRecordingStops recording using Unity's official microphone module, triggering the OnRecordingEnd event.
PushAudioManually pushes the audio wave data to the server.
StopAudioStop the current audio session.
StartAudioStart the current audio session.
CalibrateRecalculate the background noise (including bg music, etc)
Please call it whenever audio environment changed in your game.
StartWebMicrophoneStart microphone sampling in WebGL.
StartMicrophoneStart the microphone sampline by target audio device.deviceName: the name of the target device.