Audio Input State
By default, the Anam client starts capturing input audio from the user’s microphone when a session starts and stops capturing when the session ends. For certain use cases, you may wish to control the input audio state programmatically.The InputAudioState Type
TheInputAudioState interface contains two properties:
Getting the Current State
To check the current input audio state:Mute Audio Input
To mute the input audio:If you mute the input audio before starting a stream, the session will start with microphone input disabled.
Unmute Audio Input
To unmute the input audio:Changing Audio Input Device
To switch to a different microphone during an active session:You must be actively streaming to change the audio input device. This method throws an error if called before
streamToVideoElement().Configuration Options
Disabling Audio Input
To completely disable microphone input (useful for text-only interactions or when using custom input streams):disableInputAudio is true:
- The SDK will not request microphone permissions
muteInputAudio()andunmuteInputAudio()will have no effect- Any user-provided audio stream will be ignored
Specifying an Audio Device
To use a specific microphone at initialization:Custom Input Streams
If you wish to control the microphone input audio capture yourself, you can pass your ownMediaStream object when starting a stream:
The
userProvidedMediaStream object must be an instance of MediaStream and the user input audio should be the first audio track returned from the MediaStream.getAudioTracks() method.
