open-index/open-npm huggingface dataset:
npm package: @kang16hou/rnnoise-wasm
Description: WebAssembly build of RNNoise
Author: kang16hou
Latest version: 1.0.1

# x3-rnnoise-wasm

[![npm version](https://badge.fury.io/js/@kang16hou%2Frnnoise-wasm.svg)](https://badge.fury.io/js/@kang16hou%2Frnnoise-wasm)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

将 [RNNoise](https://github.com/xiph/rnnoise) 编译为 WebAssembly (Wasm) 以便在浏览器中使用的库。

RNNoise 是一个基于深度学习的音频降噪算法，可以有效地去除音频中的背景噪声。

## 安装

```console
npm install --save @kang16hou/rnnoise-wasm
```

```console
pnpm add @kang16hou/rnnoise-wasm
```

## 使用方法

```typescript
import { Rnnoise } from "@kang16hou/rnnoise-wasm";

// 加载 RNNoise 的 wasm 文件
Rnnoise.load().then((rnnoise) => {
    // 创建降噪实例
    const denoiseState = rnnoise.createDenoiseState();

    // 对音频帧应用降噪处理
    const frame = new Float32Array(...);
    denoiseState.processFrame(frame);

    ...

    // 销毁实例并释放 wasm 分配的内存
    denoiseState.destroy();
});
```

## 构建方法

已在 Ubuntu 24.04 和 macOS 15 上验证构建。

### 前置要求

- [Emscripten SDK](https://github.com/emscripten-core/emsdk) 4.0.8
- Ubuntu 24.04: `sudo apt install -y autoconf automake libtool`
- macOS 15: `brew install autoconf automake libtool`

### 构建步骤

```bash
./build-rnnoise.sh
```

```bash
pnpm install
pnpm build
pnpm dev
```

访问 <http://localhost:5173/> 可以查看 RNNoise-Wasm 的运行效果。

## 许可证

[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)

本项目基于 Shiguredo Inc. 的 rnnoise-wasm 项目修改而来。

```text
Copyright 2021-2025, Takeru Ohta (Original Author)
Copyright 2021-2025, Shiguredo Inc.
Copyright 2025, kang16hou

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

生成的 wasm 文件的许可证请参考 [rnnoise/COPYING](https://github.com/xiph/rnnoise)。

## 致谢

本项目基于 [Shiguredo Inc.](https://github.com/shiguredo) 的 [rnnoise-wasm](https://github.com/shiguredo/rnnoise-wasm) 项目。