npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rtc-ai-denoiser

v1.1.7

Published

AI denoiser plugin for TRTC Web SDK

Downloads

1,302

Readme

The RTCAIDenoiser plugin can be used in conjunction with the TRTC Web SDK to reduce noise during calls and reduce the impact of ambient sound on calls.

NPM version NPM downloads Documents

English | 简体中文

Overview

The RTCAIDenoiser plugin can be used in conjunction with the TRTC Web SDK to reduce noise during calls and reduce the impact of ambient sound on calls.

This article describes how to use the RTCAIDenoiser plugin in developing TRTC applications to apply AI noise reduction to streams when publish. Click to experience the noise reduction demo online.

Prerequisites

From 1 April 2023, TRTC monthly subscription Premium and higher is required to use the AI noise reduction function.

Supported browsers: Chrome 66+, Edge 79+, Safari 14.1+, Firefox 76+.

For better use of AI noise reduction, it is recommended that you use the latest version of Chrome.

Notes:

If there is background music captured by your microphone, RTCAIDenoiser may eliminate it as noise.

Feature Description

Step1. Install RTCAIDenoiser

npm install rtc-ai-denoiser@latest

The RTCAIDenoiser plugin needs to be installed in the same scope as TRTC.

import TRTC from 'trtc-js-sdk';
import RTCAIDenoiser from 'rtc-ai-denoiser';

Step2. Integrated RTCAIDenoiser

Dynamically loading file dependencies: The RTCAIDenoiser plugin relies on a number of files. To ensure that your browser can load and run these files properly, you need to complete the following steps.

Publish the denoiser-wasm.js file from the node_modules/rtc-ai-denoiser/assets directory to a CDN or static resource server and under the same public path. When creating RTCAIDenoiser instances later, you need to pass in the URL of the above public path and the plugin will load the dependency files dynamically.

  • If the Host URL of the file in the assets directory does not match the Host URL of the web application, you need to enable the CORS policy for accessing the file domain.
  • You cannot place assets directory files under an HTTP service, as loading HTTP resources under an HTTPS domain is prohibited by browser security policies.

Step3. Init RTCAIDenoiser

  1. Reference Quick Start Call to implement a basic audio/video call process.

  2. init RTCAIDenoiser

// Create an instance, passing in the public path where the files in the assets directory are located
const rtcAIDenoiser = new RTCAIDenoiser({ assetsPath: './assets' });
  1. create denoiserProcessor instance
const processor = await rtcAIDenoiser.createProcessor({
  sdkAppId,
  userId,
  userSig
});
  1. handle localStreams that need to be published.
// init stream
const localStream = TRTC.createStream({ video: true, audio: true });
await localStream.initialize();

// adding noise suppression to localStream
await processor.process(localStream);
// publish
await client.publish(localStream);
  1. Control whether the plugin is turned on or off: call the enable method and the disable method.
if (processor.enabled) {
  await processor.disable();
} else {
  await processor.enable();
}
  1. Dump the audio data during the noise suppression process: call the startDump method to start and the stopDump method to end, and listen to the ondumpend callback to get the audio and video data.
processor.on('ondumpend', ({ blob, name }) => {
  const url = window.URL.createObjectURL(blob);

  let anchor = document.createElement('a');
  anchor.href = url;
  anchor.download = `${name}-${Date.now()}.wav`;
  anchor.click();
  window.URL.revokeObjectURL(url);
  anchor.href = '';
});

API Description

RTCAIDenoiser

const rtcAIDenoiser = new RTCAIDenoiser({ assetsPath: './assets' })

isSupported()

Determine whether the current environment supports RTCAIDenoiser.

if (!rtcAIDenoiser.isSupported()) {
  console.log('Your browser is not supported RTCAIDenoiser');
}

createProcessor(params)

create denoiserProcessor instance.

const denoiserProcessor = await rtcAIDenoiser.createProcessor({
  sdkAppId,
  userId,
  userSig
});

Params:

| Name | Type | Description | |----------|----------|------------------------------------| | sdkAppId | number | sdkAppId that your application use | | userId | string | userId that current client use | | userSig | string | userSig signature |

Processor

process(LocalStream)

Add noise suppression to the audio of the local stream.

await denoiserProcessor.process(localStream);

get enabled

Whether AI noise suppression is currently turned on.

const enabled = denoiserProcessor.enabled

enable()

Turn on AI noise reduction.

await denoiserProcessor.enable()

disable()

Turn off AI noise reduction.

await denoiserProcessor.disable()

startDump()

Start dumping audio data from the noise reduction process. Up to 30 seconds.

denoiserProcessor.startDump()

stopDump()

Stop dumping audio data from the noise reduction process. Up to 30 seconds.

denoiserProcessor.stopDump()

on(event, handler)

add event listener to events from the processor.

eg:

After listening to the ondumpend event, the audio data is dumped and the example code is as follows.

denoiserProcessor.on('ondumpend', ({ blob, name }) => {
  const url = window.URL.createObjectURL(blob);
  let anchor = document.createElement('a');

  anchor.href = url;
  anchor.download = `${name}-${Date.now()}.wav`;
  anchor.click();
  window.URL.revokeObjectURL(url);
  anchor.href = '';
});

off(event, handler)

remove event listener to events from the processor.

destroy()

Destroy the processor to release resources and end the processor life cycle.

ChangeLog

Version 1.1.6 @2023.7.7

Improvement

Optimising performance issues.

Version 1.1.5 @2023.7.4

Improvement

Optimisation of statistics.

Version 1.1.4 @2023.6.16

Improvement

Optimize the error message.

Version 1.1.3 @2023.2.10

Improvement

Optimize the destruction logic and reduce memory usage.

Version 1.1.2 @2022.12.29

Improvement

Improve the noise reduction effect.

Version 1.1.1 @2022.12.01

Improvement

Optimize the authentication strategy.

Version 1.1.0 @2022.11.07

Improvement

Optimize the error message.

Version 1.0.0 @2022.10.19

Released version 1.0.0.