VidyoPlatform
  • Getting Started
  • Building custom client web application using Connector SDK
  • Android Integration
  • Resources
  • Use-Cases
    • Closed Captioning
    • Virtual Background - Banuba SDK
    • Calls Recording
    • Automatic Reconnection
    • Call Moderation
      • UnlockRoom API
      • Lock Room API
      • SetRoomPIN API
      • Remove RoomPIN API
      • Request Moderator Role API
      • Remove Moderator Role
      • Soft Mute
        • Soft Mute Audio
        • Soft Mute Video
      • Hard Mute
        • Hard Mute Audio
        • Hard Mute Video
      • Recording
      • Drop Participant
    • Custom noise suppression in web applications
    • Android: Picture-in-picture Mode
    • New Generation Renderer
    • Integrating with Epic
  • Twilio to Vidyo Migration
    • Twilio JavaScript SDK to VidyoClient JavaScript SDK
    • Twilio Android SDK to VidyoClient Android SDK
Powered by GitBook
On this page
  • Introduction
  • API Signature
  • Usage Example
  • Prepare rnnoise plugin
  • Wire the plugin up
  • Stop the plugin
  1. Use-Cases

Custom noise suppression in web applications

This article will guide you on how to implement a custom noise cancelation mechanism in your web application. An open-source library rnniose is used here as an example.

PreviousDrop ParticipantNextAndroid: Picture-in-picture Mode

Last updated 7 months ago

Introduction

Some developers using our Native WebRTC SDK may find it useful to enhance audio processing, especially noise cancelation, in order to improve overall audio quality and basically make it better than what WebRTC stack provides out-of-the-box.

Starting from 24.1.0 we have included a new API that will allow developers to intercept local microphone stream, process it, and then send it to remote participants. For simplicity, we took open-source library and integrated it into our sample application (that you always can find within SDK package) through the new API. So encourage you to take a look at it, play with it, and use it even as-is.

API Signature

RegisterLocalMicrophoneStreamInterceptor

RegisterLocalMicrophoneStreamInterceptor(interceptor: 
VidyoLocalMicrophoneStreamInterceptor
): Promise<boolean>

Parameters

interceptor: VidyoLocalMicrophoneStreamInterceptor

Returns

Promise<boolean>

Usage Example

Following steps will show you how to integrate into your application. Please refer to the sample application within SDK package for complete code base.

Prepare rnnoise plugin

The entire plugin is already there in our sample app. We won't dive into its details and how it works, so just be sure you have the following files included into your project:

Wire the plugin up

In order rnnoise to start acting, you have to register it as an interceptor of local microphone stream:

const rnnoisePlugin = await import('./rnnoise/index.js');

vidyoConnector.RegisterLocalMicrophoneStreamInterceptor(rnnoisePlugin.start);

In the sample application we have added a very simple UI for selecting custom audio processor, and here is how it looks like in VidyoConnector.js:

async function handleMicrophoneInterceptor(vidyoConnector) {
    const rnnoisePlugin = await import('./rnnoise/index.js');
    $("#microphoneInterceptor").change(async ({ target }) => {
        const val = $(target).val();
        try {
            switch (val) {
                case 'rnnoise':
                    vidyoConnector.RegisterLocalMicrophoneStreamInterceptor(rnnoisePlugin.start);
                    break;
                default:
                    rnnoisePlugin.stop();
                    vidyoConnector.UnregisterLocalMicrophoneStreamInterceptor();
                    break;
            }
        } catch(e) {
            console.error('microphoneInterceptor on chnage error:', e);
        }
    });
}

Stop the plugin

In order to disable this custom noise suppression, you have to stop rnnoise processor itself first, and then unregister local microphone stream interceptor:

rnnoisePlugin.stop();
vidyoConnector.UnregisterLocalMicrophoneStreamInterceptor();
VidyoClient WebRTC Javascript Library
rnnoise
rnnoise