rkd-noise-suppression-napi (0.2.3-rc.3)

Published 2026-11-21 14:35:34 +01:00 by shjackal

Installation

[registries.forgejo]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add rkd-noise-suppression-napi@0.2.3-rc.3 --registry forgejo

About this package

Node.js native bindings for rkd-noise-suppression-core

rkd-noise-suppression-napi

Node.js native bindings for rkd-noise-suppression-core. Loadable from Electron, Node, or any Node-compatible runtime via N-API.

Status — Phase 3a-1

  • ✓ Builds for the developer's host platform via napi build --platform --release
  • ✓ Exposes Denoiser with processFrame(input: Float32Array, output: Float32Array), reset(), frameSizeAt48k
  • ✓ Smoke test in test.mjs covers passthrough + real-model paths
  • ✓ Real-model SNR validated at -18.1 dB attenuation in silent regions (synthesized noisy signal)
  • ⨯ Multi-platform CI matrix → Phase 3a-2
  • ⨯ Bundled onnxruntime shared lib → Phase 3a-2 (today: ORT_DYLIB_PATH env var)
  • ⨯ npm publish → Phase 3a-2

Build

cd crates/napi
npm install
npm run build      # release build
npm run build:debug

Produces rkd-noise-suppression.<platform-triple>.node plus auto-generated index.js and index.d.ts.

Test

Passthrough only (no model required):

npm test

With real model — requires models/dfn2/ populated and ORT_DYLIB_PATH set (see models/README.md at the workspace root):

ORT_DYLIB_PATH=<path-to-onnxruntime> npm test

The Denoiser constructor reads ORT_DYLIB_PATH at startup and pre-loads the ONNX Runtime library before deepfilter-rt's bare-name init runs. On Windows this avoids picking up stale onnxruntime.dll from System32.

Use from Node / Electron

const { Denoiser } = require("rkd-noise-suppression");

// Passthrough (no real inference; output ≈ input)
const passthrough = new Denoiser(null, 48000);

// Real DFN2 inference (set ORT_DYLIB_PATH first)
const real = new Denoiser("/abs/path/to/models/dfn2", 48000);

const input = new Float32Array(real.frameSizeAt48k);  // 480 samples
const output = new Float32Array(real.frameSizeAt48k);
// fill input with mic samples...
real.processFrame(input, output);
// output now contains denoised samples

The 480-sample frame size is fixed (10 ms @ 48 kHz). Buffer arbitrary-length inputs to align on frame boundaries — same contract as the Rust core. For an Electron app, run the napi binding on a Worker thread; the audio capture worklet pushes 128-sample quanta into a shared ring (Phase 3c).

Sample rate

Currently sampleRate must equal 48000. processFrame is only valid at 48 kHz; non-48k pipelines must resample first (e.g. via Web Audio's AudioContext({ sampleRate: 48000 })). Exposing the Rust core's arbitrary-rate process() is a future enhancement.

License

Apache-2.0. See workspace root.

Dependencies

ID Version
napi ^2
napi-derive ^2
ort =2.0.0-rc.11
rkd-noise-suppression-core ^0.2.3-rc.3
napi-build ^2
Details
Cargo
2026-11-21 14:35:34 +01:00
1
2026-11-22 14:37:37 +01:00
Apache-2.0
17 KiB
Assets (1)
Versions (8) View all
0.2.3-rc.3 2026-11-21
0.2.3-rc.2 2026-11-21
0.2.3-rc.1 2026-11-21
0.2.1 2026-06-10
0.2.0 2026-06-10