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

ai-noise-reduction

v0.0.1

Published

AI模型音频降噪

Downloads

14

Readme

AI 降噪

开发过程中,或者需要小猪进一步优化,可以联系小猪,关注小猪抖音账号:chuntianxiaozhu 交流更多技术

web RTC 音频解析流程

流程图

采集->编码->传输->解码->播放

本模块主要在编码阶段将输入声道的节点进行解析处理,然后再传输出去

用法

var globalStream;
var globalAiDenoiser;

async function initAudioData(stream) {
  globalStream = stream;
  const audioContext = new AudioContext();
  globalAiDenoiser = new Ctxz.AIDenoiser({
    assetsPath: wasmPath,
    context: audioContext,
    ains: true,
    agc: true,
    bufferTime: 30,
    dumpBundleNums: 3,
    threshold: 2,
  });
  globalAiDenoiser.on("overload", (elapsedTime) => {
    // 如果处理超时转换成性能消耗更小的稳态降噪
    globalAiDenoiser.setMode(Ctxz.AIDenoiserProcessorMode.STATIONARY_NS);
  });
  await globalAiDenoiser.init();
  globalAiDenoiser.dump();
  const source = audioContext.createMediaStreamSource(stream);
  const aiDenoiserNode = globalAiDenoiser.connect(source, audioContext);
  aiDenoiserNode.connect(audioContext.destination);
  // 初始设置成AI降噪模式
  globalAiDenoiser.setMode(Ctxz.AIDenoiserProcessorMode.NSNG);
  // 推荐设置成舒缓降噪
  globalAiDenoiser.setLevel(Ctxz.AIDenoiserProcessorLevel.SOFT);
}

async function recordSound() {
  navigator.mediaDevices
    .getUserMedia({
      audio: {
        // andoird机器上不需要设置
        sampleRate: 48000,
        // sampleSize: ,
        channelCount: 2,
        autoGainControl: true,
        echoCancellation: true,
        noiseSuppression: false,
        googHighpassFilter: true,
        // 选择设备
        // deviceId: {
        //     exact:
        // }
      },
    })
    .then(initAudioData)
    .catch((e) => {
      console.log(e);
    });
}

function stopSound() {
  globalAiDenoiser.destroy();
  globalStream.getTracks().forEach((track) => {
    if (track.readyState === "live") {
      track.stop();
    }
  });
}

// 启用降噪
globalAiDenoiser && globalAiDenoiser.enable();

// 禁用降噪
globalAiDenoiser && globalAiDenoiser.disable();

API

checkCompatibility

检查当前浏览器是否支持降噪

enable

开启降噪

disable

禁用降噪

setMode

设置降噪模式

NSNG:模型降噪。该模式可以压制噪声类型中的稳态与非稳态噪声。
STATIONARY_NS:稳态降噪。该模式仅压制稳态噪声,建议仅在模型降噪处理耗时过长时使用。

setLevel

设置降噪强度

SOFT:(推荐)舒缓降噪。
AGGRESSIVE:激进降噪。将降噪强度提高到激进降噪会增大损伤人声的概率

dump

转储降噪处理过程中的音频数据,方便定位和分析降噪处理的问题

  • 音频数据所处的阶段,有以下三种
  1. input:待降噪的音频数据。
  2. ns_out:经过降噪处理的音频数据。
  3. agc_out:经过人声增强处理的音频数据。

ondump

注册转储事件

globalAiDenoiser.on("dump", (blob, name) => {}

onoverload

降噪处理耗时过长回调

  • elapsedTime:插件处理一帧音频的时间(毫秒)

在这里主要感谢声网 降噪 AI 模型,模块持续优化