AI Noise Suppression

Updated

Suppress hundreds of types of noise and reduce distortion for human voice

AI Noise Suppression enables you to suppress hundreds of types of noise and reduce distortion in human voices when multiple people speak at the same time. In use-cases such as online meetings, online chat rooms, video consultations with doctors, and online gaming, AI Noise Suppression makes virtual communication as smooth as face-to-face interaction.

Try out the online demo for AI noise suppression.

AI Noise Suppression reduces the following types of noise:

  • Television
  • Kitchen
  • Street, such as birds chirping, traffic, and subway sounds
  • Machine, such as fans, air conditioners, vacuum cleaners, and copiers
  • Office, such as keyboard and mouse clicks
  • Household, such as doors opening, creaking chairs, crying babies, and house renovations
  • Constant knocking
  • Beeps and clapping
  • Music

You can choose following noise reduction strategies:

  • Default: Reduces noise to a comfortable level without distorting human voice.
  • Custom: A more enhanced or customized noise reduction strategy for your business use-case. Contact support@agora.io for details.

Want to try out AI Noise Suppression? Use the online demo.

Understand the tech

In the pre-processing stage, AI Noise Suppression uses deep learning noise reduction algorithms to modify data in the extensions pipeline.

AI noise suppression

Prerequisites

Ensure that you have implemented the SDK quickstart in your project.

Enable AI Noise Suppression

This section shows you how to integrate AI Noise Suppression into your app.

The following implementation steps apply to the latest version of the AI Noise Suppression extension. Refer to the extension release notes for details.

  1. Integrate AI Noise Suppression into your app

    The AI Noise Suppression extension (agora-extension-ai-denoiser) requires Web SDK v4.15.1 or later. In the root of your project, run the following command to install the extension. By default, this installs the latest version (v2.0.2):

    npm install agora-extension-ai-denoiser

    To install a specific extension version, use one of the following commands:

    • v2.0.2 — Adds background voice removal, which further isolates the target voice in noisy or multi-speaker scenarios.

      npm install agora-extension-ai-denoiser@2.0.2
    • v2.0.1 — Supports low-latency mode and log-level configuration. If you need background voice removal, use v2.0.2.

      npm install agora-extension-ai-denoiser@2.0.1
  2. Import AI Noise Suppression

Add the following code to your .js file.

import {AIDenoiserExtension} from "agora-extension-ai-denoiser";
  1. Dynamically load the Wasm dependencies

The AI Noise Suppression extension depends on a few Wasm files. To ensure that the browser can load and execute these files, do the following:

  1. Publish the files located in the node_modules/agora-extension-ai-denoiser/external directory to the CDN or static resource server, and put them under one public path. In subsequent steps, you need to pass in the public path URL to create an AIDenoiserExtension instance. The extension then dynamically loads these files.

    • If the host URL of the Wasm files is not the same as that of the web application, enable the CORS policy.
    • Do not put the Wasm files in an HTTP service, loading HTTP resources in the HTTPS domain is blocked by the browsers' security policy.
  2. If you have enabled the Content Security Policy (CSP), because Wasm files are not allowed to load in Chrome and Edge by default, you need to configure the CSP as follows:

    • For versions later than Chrome 97 and Edge 97 (Chrome 97 and Edge 97 included): Add 'wasm-unsafe-eval' and blob: in the script-src options. For example:

       <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'wasm-unsafe-eval' blob:">
    • For versions earlier than Chrome 97 and Edge 97: Add 'unsafe-eval' and blob: in the script-src options.

  3. Register the AI Noise Suppression extension

Call AgoraRTC.registerExtensions, and pass in the created AIDenoiserExtension instance. Optionally, listen for the callback reporting that the Wasm and JS files fail to load.

// Create an AIDenoiserExtension instance, and pass in the host URL of the Wasm files
const denoiser = new AIDenoiserExtension({assetsPath:'./external'});
// Check compatibility
if (!denoiser.checkCompatibility()) {
 // The extension might not be supported in the current browser. You can stop executing further code logic
 console.error("Does not support AI Denoiser!");
}
// Register the extension
AgoraRTC.registerExtensions([denoiser]);
// (Optional) Listen for the callback reporting that the Wasm files fail to load
denoiser.onloaderror = (e) => {
 // If the Wasm files fail to load, you can disable the extension, for example:
 // openDenoiserButton.enabled = false;
 console.log(e);
}

Best practice is to create one AIDenoiserExtension instance only.

  1. Create an IAIDenoiserProcessor instance

Call the createProcessor method to create a processor, and set whether to enable the extension by default. If you do not set the default state, the extension inherits the previous state.

// Create a processor
const processor = denoiser.createProcessor();
// Enable the extension by default
processor.enable();
// Disable the extension by default
// processor.disable();
  1. Inject the extension to the audio processing pipeline

Call pipe and specify the processorDestination property.

// Create a local video track
const audioTrack = await AgoraRTC.createMicrophoneAudioTrack();
// Inject the extension to the audio processing pipeline
audioTrack.pipe(processor).pipe(audioTrack.processorDestination);
await processor.enable();
  1. Enable or disable the extension

Call the enable or disable methods as needed.

() => {
 if (processor.enabled) {
  await processor.disable();
 } else {
  await processor.enable();
 }
}
  1. Set the noise suppression mode and level

    // Listen for the callback reporting that the noise suppression process takes too long
    processor.on("overload", async (elapsedTime) => {
     console.log("overload!!!");
     // Switch to steady-state noise reduction mode, temporarily disable AI noise reduction.
     await processor.setMode("STATIONARY_NS");
     // Completely disable AI noise reduction and use the browser's built-in noise reduction.
     // await processor.disable()
    });
  2. Dump audio data

Best practice for logging is to dump audio data. This significantly improves the efficiency of troubleshooting. To do this, call the dump method and listen for the dump and dumpend events to dump the audio data during the noise suppression process.

processor.on("dump", (blob, name) => {
 // Dump the audio data files generated during the noise suppression process to your local machine in .pcm format.
 const objectURL = URL.createObjectURL(blob);
 const tag = document.createElement("a");
 tag.download = name;
 tag.href = objectURL;
 tag.click();
 setTimeout(() => {URL.revokeObjectURL(objectURL);}, 0);
});

processor.on("dumpend", () => {
 console.log("dump ended!!");
});

processor.dump();

Reference

This section completes the information on this page, or points you to documentation that explains other aspects about this product.

API reference

This section provides the API reference for the AI Denoiser extension.

IAIDenoiserExtension

checkCompatibility

Checks whether the current browser supports the AI Denoiser extension. The result returned by this method is for reference only.

checkCompatibility(): boolean;

Since v1.1.0

createProcessor

Creates an IAIDenoiserProcessor instance.

createProcessor(): IAIDenoiserProcessor;
setLogLevel

Sets the log level. For available log levels, see AIDenoiserLogLevel.

public setLogLevel(level: AIDenoiserLogLevel)

Since v2.0.0

onloaderror

Callback for Wasm dependency file loading failures.

onloaderror?: (error: Error) => void;

Deprecated since v2.0.0

IAIDenoiserProcessor

kind

The processor type, either video or audio.

get kind(): 'video' | 'audio';
enabled

Whether the extension is enabled:

  • true: Enabled.
  • false: Not enabled.
get enabled(): boolean;
enable

Enables the AI denoising feature.

enable(): void | Promise<void>;
disable

Disables the AI denoising feature.

disable(): void | Promise<void>;

This method must be called after pipe.

setMode

Sets the denoising mode.

setMode(mode: AIDenoiserProcessorMode): Promise<void>;

Since v1.1.0

You can call this method in the onoverload callback to switch to stationary noise suppression to reduce overhead. See AIDenoiserProcessorMode for details.

This method must be called after pipe.

setLevel

Sets the denoising intensity. See AIDenoiserProcessorLevel for details.

setLevel(level: AIDenoiserProcessorLevel): Promise<void>;

Since v1.1.0

This method must be called after pipe.

setLatency

Sets the denoising latency level. See AIDenoiserProcessorLatency for details.

setLatency(latency: AIDenoiserProcessorLatency): Promise<void>;

Since v2.0.0

This method must be called after pipe.

dump

Dumps audio data during the denoising process to help troubleshoot and analyze denoising issues.

dump(): void;

This method must be called after pipe.

Calling this method triggers 9 dump events, returning audio data processed by the extension 30 seconds before and 60 seconds after the method call, for a total of 9 audio files (see audio file description). Then it triggers the dumpend event, indicating that the audio data dump has completed.

Audio file description

Each audio file is encoded in PCM format with a duration of 30 seconds. The filename contains the following information:

  • The processing stage of the audio data, one of the following:
    • input: Audio data awaiting denoising.
    • ns_out: Audio data after noise suppression.
    • agc_out: Audio data after voice enhancement.
  • Audio sample rate.
  • Number of channels.
  • Dump time: If the dump time is T (in seconds), the file contains audio data from the range [T-30, T].

Example audio filename: input_16000hz_1ch_0.pcm

Note

  • If you disable AI denoising before the dump event triggers 9 times, the dump process terminates immediately and triggers the dumpend event. In this case, fewer than 9 audio data files are returned.
  • If the extension processes less than 30 seconds of audio, the corresponding audio file duration is also less than 30 seconds.
ondump

Callback for dumping audio data.

ondump?: (blob: Blob, name: string) => void;

Deprecated since v2.0.0

This callback returns the following parameters:

  • blob: The audio data file.
  • name: The name of the audio data file.
ondumpend

Callback indicating that audio data dumping has completed.

ondumpend?: () => void;

Deprecated since v2.0.0

onoverload

Callback for when denoising processing takes too long.

onoverload?: (elapsedTime: number) => void;

Deprecated since v2.0.0

Parameters

  • elapsedTime: The time (in milliseconds) the extension takes to process one audio frame. This value is for reference only; precision depends on the browser's timing accuracy. For example, Firefox has lower time precision.
on callbacks

Listens for events.

on(event: "pipeerror", listener: AIDenoiserProcessorPipeErrorCallback): void;
on(event: "overload", listener: AIDenoiserProcessorOverloadCallback): void;
on(event: "dump", listener: AIDenoiserProcessorDumpCallback): void;
on(event: "dumpend", listener: AIDenoiserProcessorDumpEndCallback): void;

Since v2.0.0, the AI Denoiser extension listens for the following events using the on method:

  • pipeerror: Wasm dependency file loading failure event. Replaces the onloaderror callback.
  • overload: Denoising processing takes too long event. Replaces the onoverload callback.
  • dump: Audio data dump event. Replaces the ondump callback.
  • dumpend: Audio data dump completed event. Replaces the ondumpend callback.

Type definitions

AIDenoiserExtensionOptions

AI Denoiser extension initialization parameters.

export interface AIDenoiserExtensionOptions {
 assetsPath: string
}

Parameters

  • assetsPath: The URL path to the Wasm files required by the AI Denoiser extension. Do not include a trailing slash in the path, for example, ./external.

The extension constructs the full path to the Wasm file based on assetsPath. If an incorrect path causes the Wasm file to fail loading, you receive a pipeerror event.

AIDenoiserProcessorMode

Denoising mode.

export enum AIDenoiserProcessorMode {
 NSNG = "NSNG",
 STATIONARY_NS = "STATIONARY_NS",
}

Values

  • NSNG: Hybrid noise reduction. This mode suppresses both stationary and non-stationary noise types.
  • STATIONARY_NS: Stationary noise suppression. This mode only suppresses stationary noise. Use this mode only when AI denoising processing takes too long.
AIDenoiserProcessorLevel

Denoising intensity.

export enum AIDenoiserProcessorLevel {
 SOFT = "SOFT",
 AGGRESSIVE = "AGGRESSIVE",
}

Values

  • SOFT: (Recommended) Soft denoising.
  • AGGRESSIVE: Aggressive denoising. Increasing the denoising intensity to aggressive increases the probability of damaging the voice signal.
AIDenoiserLogLevel

AI Denoiser extension log level.

export enum AIDenoiserLogLevel {
 DEBUG = "DEBUG",
 INFO = "INFO",
 WARN = "WARN",
 ERROR = "ERROR",
 NONE = "NONE",
}

Values

  • DEBUG: (0) Prints debug information, general information, warnings, and error logs.
  • INFO: (1) Prints general information, warnings, and error logs.
  • WARN: (2) Prints warnings and error logs.
  • ERROR: (3) Prints error logs only.
  • NONE: (4) Prints no logs.
AIDenoiserProcessorLatency

AI denoising latency level.

export enum AIDenoiserProcessorLatency {
 LOW = "LOW",
 FULL = "FULL",
}

Values

  • LOW: Low latency mode (approximately 40 ms). In this mode, denoising performance is slightly reduced.
  • FULL: High latency mode.

Considerations

Currently, AI Noise Suppression has the following limitations:

  • If only some of the audio tracks on the current web page enable AI Noise Suppression, audio tracks that do not enable AI Noise Suppression could be affected. This is because AI Noise Suppression turns on AEC and AGC and turns off NS in the browser.
  • Although AI Noise Suppression supports Safari v14.1 and greater, there are performance issues. Best practice is to not support Safari.
  • AI Noise Suppression does not support browsers on mobile devices.