@ennuicastr/webrtcaec3.js

中文文档
0.3.0发布于 2024/01/02BSD-3-ClauseTypeScriptCommonJS零依赖近 30 天下载 3.5万

Port of WebRTC's AEC3 (acoustic echo canceller, version 3) library to WebAssembly/JavaScript

原始使用文档

This is a port of WebRTC's AEC3 (acoustic echo cancellation... 3) library to WebAssembly and JavaScript, so that echo cancellation can be performed on any audio, rather than trusting whatever echo cancellation getUserMedia wishes to do.

The Google WebRTC implementation from which this is derived is under a 3-clause BSD license, and so a compiled version of this library falls under the same license. The small amount of glue code provided by this library itself is under the so-called “0-clause BSD license” and does not require attribution. Additionally, library components used by WebRTC are under the Apache 2 license.

API

Include webrtcaec3.js, or import or require this library as a module. Once the library is loaded, WebRtcAec3 is a function which returns a promise for a WebRtcAec3 module instance. With a WebRtcAec3 module instance AEC3, AEC3.AEC3 is a constructor for an AEC3 instance, taking three parameters: the sample rate, and the number of channels for the render (output) and capture (input) streams, respectively. The AEC3 library itself is synchronous, so if you need asynchrony, use it in a WebWorker.

Putting that together:

const AEC3 = await WebRtcAec3();
const aec = new AEC3(sampleRate, outputChannels, inputChannels);

Note that not all sample rates will work. In fact, most won't. Basically, use 48000.

The AEC3 instances expose three methods: analyze, processSize, and process. Use analyze to analyze render (output) data:

aec.analyze(outputData /* Float32Array[] */);

Use process to process capture (input) data, cancelling echo. It deposits the processed data into an output buffer which you must provide. You can use processSize to get the necessary size of each channel of the output buffer.

const bufSz = aec.processSize(inputData);
const outBuf = [new Float32Array(bufSz)]; // one per channel
aec.process(outBuf, inputData /* Float32Array[] */);
... do something with outBuf ...

analyze, processSize, and process each take an optional “options” argument, which in particular can take a sample rate for the input data. If the sample rate for the input data does not match the sample rate with which the AEC3 instance was created, it will be resampled.

For further documentation on each method, see the types file.

版本与发布记录

@ennuicastr/webrtcaec3.js 共发布 6 个版本,首次发布于 2023/12/28;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.3.0latest2024/01/022 年前
0.2.12023/12/312 年前
0.2.02023/12/302 年前
0.1.22023/12/292 年前
0.1.12023/12/292 年前
0.1.02023/12/282 年前

关于 @ennuicastr/webrtcaec3.js 的常见问题

@ennuicastr/webrtcaec3.js 是什么?

Port of WebRTC's AEC3 (acoustic echo canceller, version 3) library to WebAssembly/JavaScript

如何安装 @ennuicastr/webrtcaec3.js?

在项目目录运行 npm install @ennuicastr/webrtcaec3.js,或使用 pnpm add / yarn add / bun add。

@ennuicastr/webrtcaec3.js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ennuicastr/webrtcaec3.js 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@ennuicastr/webrtcaec3.js 可以商用吗?

@ennuicastr/webrtcaec3.js 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@ennuicastr/webrtcaec3.js 的下载量有多少?

根据 npm 官方下载统计,@ennuicastr/webrtcaec3.js 在 2026/10/14 – 2026/11/12 这 30 天内被下载 34,641 次,日均约 1,155 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ennuicastr/webrtcaec3.js 还在维护吗?

最新版本 0.3.0 发布于 2024/01/02(2 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/12/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。