Accessing the Local Audio Stream

The Communications SDK 3.8 for Android and iOS allows accessing the local participant's audio stream before sending the stream through an open session. You may use it to build speech recognition or audio moderation. The following steps present a basic implementation of this feature.


The feature requires using one of the following SDKs:

  • Android Client SDK 3.8 or later
  • iOS Client SDK 3.8 or later

Start capturing audio

To access the local participant's audio stream, implement a delegate or a callback responsible for capturing the local audio stream. On iOS, add an implementation that conforms the AudioDelegate protocol to your class and uses the audioRecordSamplesReady callback. On Android, implement the LocalInputAudioCallback instance.

extension YourClass: AudioDelegate {
  func audioRecordSamplesReady(samples: AudioSamples) {
    guard let abl = UnsafeMutableAudioBufferListPointer(samples.bufferList) else { return }
    let sampleRate = samples.sampleRate
    let audioFormat = samples.format
    for buffer in abl {
      let channelCount = buffer.mNumberChannels
      // Input audio samples are ready to use
      let newData = Data(bytes: buffer.mData!, count: Int(buffer.mDataByteSize))
LocalInputAudioCallback callback = new LocalInputAudioCallback() {
    public void onSample(LocalInputAudioSamples sample) {
        // The sample provides access to getAudioFormat(), getChannelCount(), getData(), and getSampleRate()
val audioSampleCallback = LocalInputAudioCallback {
    // This provides access to audioFormat, channelCount, data, and sampleRate

Then, start capturing the local audio stream. On iOS, set your class as an audio delegate for On Android, call the registerLocalInputAudioCallback using

let yourClass = YourClass() = yourClass
LocalInputAudioCallback callback = // Your instance;
val callback = LocalInputAudioCallback { }

After this step, the delegate and the callback will be called whenever the local participant's audio is processed in a conference, allowing you to save samples for later use or real-time analysis.

Stop capturing audio

To stop capturing audio, set the delegate to nil on iOS or call the unregisterLocalInputAudioCallback on Android. = nil
LocalInputAudioCallback callback = // Your instance;
LocalInputAudioCallback callback = // Your instance