Noise Cancellation

Noise Cancellation capabilities of our Plain-JS Video SDK can be enabled by installing our @stream-io/audio-filters-web plugin. Under the hood, this package uses the technology developed by krisp.ai.

Compatibility

This plugin currently supports only modern desktop browsers:

  • Chrome, Firefox and Edge
  • Safari 17.4.1+

Install the plugin

With your favourite package manager, run the following command:

yarn add @stream-io/audio-filters-web
# or
npm install @stream-io/audio-filters-web

Integration

In the following code snippet, we show how to check if а platform is supported, initialize the plugin, and enable/disable it.

import { NoiseCancellation } from "@stream-io/audio-filters-web";

const call = client.call(type, id);
await call.get(); // or call.getOrCreate()

const noiseCancellation = new NoiseCancellation();
const isSupported = await noiseCancellation.isSupported();
if (isSupported) {
  await noiseCancellation.init();
  await call.microphone.enableNoiseCancellation(noiseCancellation);
}

// disable it and unregister the plugin
await call.microphone.disableNoiseCancellation();

NoiseCancellation API

The NoiseCancellation class exposes the following methods:

// creates a new NoiseCancellation instance
const noiseCancellation = new NoiseCancellation();

// returns true for supported platforms
await noiseCancellation.isSupported();

// initializes the plugin
await noiseCancellation.init();

// will temporarily disable NC (doesn't unregister the plugin)
noiseCancellation.disable();

// will enable NC (requires the plugin to be registered first)
noiseCancellation.enable();

// returns true if NC is enabled
const isEnabled = await noiseCancellation.isEnabled();

// sets the suppression level [0, 100]
// where 0 is no suppression and 100 is maximum suppression
// the default value is 100
noiseCancelation.setSuppressionLevel(50);

// listen for state updates
const off = noiseCancellation.on("change", (v) => {
  console.log(`Noise Cancellation is ${v ? "enabled" : "disabled"}`);
});
© Getstream.io, Inc. All Rights Reserved.