https://github.com/sapphi-red/web-noise-suppressor
Noise suppressor nodes for Web Audio API.
https://github.com/sapphi-red/web-noise-suppressor
noise-cancellation noise-reduction noise-suppression webaudio webaudio-api webaudioapi
Last synced: about 1 month ago
JSON representation
Noise suppressor nodes for Web Audio API.
- Host: GitHub
- URL: https://github.com/sapphi-red/web-noise-suppressor
- Owner: sapphi-red
- License: mit
- Created: 2022-01-24T11:51:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-03T02:51:35.000Z (9 months ago)
- Last Synced: 2025-03-31T05:04:06.533Z (about 2 months ago)
- Topics: noise-cancellation, noise-reduction, noise-suppression, webaudio, webaudio-api, webaudioapi
- Language: TypeScript
- Homepage: https://web-noise-suppressor.sapphi.red/
- Size: 264 KB
- Stars: 48
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @sapphi-red/web-noise-suppressor
[](https://badge.fury.io/js/@sapphi-red%2Fweb-noise-suppressor) 
Noise suppressor nodes for Web Audio API.
[Demo](https://web-noise-suppressor.sapphi.red)
This package provides three noise suppression nodes.
- NoiseGateWorkletNode: A simple noise gate implementation
- RnnoiseWorkletNode: Based on [xiph/rnnoise](https://github.com/xiph/rnnoise)
- Using [shiguredo/rnnoise-wasm](https://github.com/shiguredo/rnnoise-wasm)
- SpeexWorkletNode: Based on [xiph/speexdsp](https://github.com/xiph/speexdsp)'s `preprocess` function
- Using [sapphi-red/speex-preprocess-wasm](https://github.com/sapphi-red/speex-preprocess-wasm)**This package requires AudioWorklet to work.**
## Install
```shell
npm i @sapphi-red/web-noise-suppressor # yarn add @sapphi-red/web-noise-suppressor
```## Usage
This section is written only for vite users.
```ts
import { SpeexWorkletNode, loadSpeex } from '@sapphi-red/web-noise-suppressor'
import speexWorkletPath from '@sapphi-red/web-noise-suppressor/speexWorklet.js?url'
import speexWasmPath from '@sapphi-red/web-noise-suppressor/speex.wasm?url' // you can use `vite-plugin-static-copy` instead of thisconst ctx = new AudioContext()
const speexWasmBinary = await loadSpeex({ url: speexWasmPath })
await ctx.audioWorklet.addModule(speexWorkletPath)const stream = await navigator.mediaDevices.getUserMedia({
audio: true
})const source = ctx.createMediaStreamSource(stream)
const speex = new SpeexWorkletNode(ctx, {
wasmBinary: speexWasmBinary,
maxChannels: 2
})source.connect(speex)
speex.connect(ctx.destination)
```For more details, see [demo source code](https://github.com/sapphi-red/web-noise-suppressor/blob/main/demo/src/index.ts).