Accessing the Local Audio Stream

The iOS SDK 3.8 and Android SDK 3.8 allow 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.

  1. 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
  1. 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.

  1. 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