Skip to main content

AudioCapture

Module: Inworld.AI. Namespace: Inworld. Inherited from MonoBehavior

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

Inspector Variables

VariableDescription
Sampling ModeThe current Sampling Mode.
Push To Talk KeyIf the keycode is defined, users can hold this key to start sampling, and release this key to stop sampling.
Player Volume ThreadThe 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.
Audio to Push CapacityIdentifies how many audioChunk can be stored before sending.
Device NameThe name of the current sampling device.
Detect Player SpeakingIf enabled, we will detect the player's speaking by the SNR and only enable it when detected. If not, we will always sample the player's speaking.
Audio EventThis component's AudioEvents.

Properties

PropertyDescription
EventGets the AudioEvents.
CurrentPlayingAudioSourceGets/Sets the current playing audio source.
VolumeGets the global setting of the volumes (From 0 to 1).
PushToTalkKeyGets/Sets the Push to talk key. The auto detecting would only be effected if this key is NONE.
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)
AutoDetectPlayerSpeakingGets/Sets if this component is detecting player speaking automatically.
IsRecordingBy default, it's controlled by the Record UI button in PlayerController.
Note: This status is overwritten by Push to talk Hot key.
IsPlayerSpeakingIndicates if the user is speaking based on audio amplitude and threshold.
IsCapturingIndicates if the microphone is currently capturing audio.
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.
PushAudioImmediateSend the audio chunk in the queue immediately to Inworld server.
PushAudioManually pushes the audio wave data to the server.
StopAudioStop the current audio session.
StartAudioStart the current audio session.
SendAudioSend the specific AudioChunkchunk: the AudioChunk to send.
CalibrateRecalculate the background noise (including bg music, etc)
Please call it whenever audio environment changed in your game.