@sapphi-red/web-noise-suppressor
TypeScript icon, indicating that this package has built-in type declarations

0.3.4 • Public • Published

@sapphi-red/web-noise-suppressor

npm version CI

Noise suppressor nodes for Web Audio API.

Demo

This package provides three noise suppression nodes.

This package requires AudioWorklet to work.

Install

npm i @sapphi-red/web-noise-suppressor # yarn add @sapphi-red/web-noise-suppressor

Usage

This section is written only for vite users.

import { SpeexWorkletNode } 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 this

const 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.

Readme

Keywords

none

Package Sidebar

Install

npm i @sapphi-red/web-noise-suppressor

Weekly Downloads

616

Version

0.3.4

License

MIT

Unpacked Size

672 kB

Total Files

20

Last publish

Collaborators

  • sapphi-red