@desert-ant-labs/clear

中文文档
4.3.0发布于 2026/11/06SEE LICENSE IN LICENSE.mdTypeScriptES Module近 30 天下载 1.8万

On-device speech enhancement for JavaScript: denoise, dereverb, and loudness-normalize to a podcast-ready 48 kHz. Runs in the browser (WebAssembly + LiteRT.js) and server-side in Node (native), from one import.

原始使用文档
文档目录5 节
  1. Usage
  2. Channels
  3. Mastering
  4. Self-hosting and progress
  5. License

@desert-ant-labs/clear

On-device speech enhancement for JavaScript. Takes a noisy mono recording (laptop mic, untreated room, traffic) and returns podcast-ready 48 kHz audio: denoise and dereverb from a fine-tuned DeepFilterNet 3, then loudness normalization to a delivery target. Everything runs locally, so the audio never leaves the device or browser.

Two entries share one Clear API:

  • @desert-ant-labs/clear (default): a WebAssembly pipeline with LiteRT.js inference (XNNPACK-accelerated CPU by default, optional WebGPU), for the browser. It has no native dependencies, so a single import builds cleanly for every target of a multi-target bundler (Next.js, Remix, SvelteKit, Nuxt), including the browser bundle and the Client-Component SSR pass those frameworks render in Node. It is safe to import during server-side rendering, but LiteRT.js needs a browser (or Web Worker) to initialize, so Clear.load() runs inference only in the browser; calling it in plain Node throws an actionable error pointing you to /native.
  • @desert-ant-labs/clear/native: a prebuilt native core (LiteRT on Linux, Core ML on macOS), for server-side inference in Node. No @litertjs/core, no build tools, no flags. Import it from server-only code (API routes, server actions, plain Node scripts). Do not import it from a component that also renders in the browser.
# Browser (default entry):
npm i @desert-ant-labs/clear @litertjs/core

# Server-side inference in Node (/native entry) needs no extra install:
npm i @desert-ant-labs/clear

Usage

import { Clear } from "@desert-ant-labs/clear";           // browser
// import { Clear } from "@desert-ant-labs/clear/native"; // server-side Node

const clear = await Clear.load();          // downloads and caches on first use
const result = await clear.enhance(samples, 48_000);

result.samples;                // Float32Array, 48 kHz mono, whatever went in
result.measuredLUFS;           // integrated loudness of the input
result.measuredTruePeakDBFS;   // true peak of the output, after limiting
result.realtimeFactor;         // above 1 is faster than real time

clear.dispose();

Input can be a Float32Array or a plain array of numbers, at any sample rate.

Channels

The output is mono by default, whatever goes in - the model is mono, so keeping a stereo pair costs an inference pass per channel (about 1.8x a mono run). Pass one entry per channel and ask to keep them:

const stereo = await clear.enhance([left, right], 48_000, { channelMode: "preserve" });
stereo.channelCount;   // 2
stereo.channels;       // [Float32Array, Float32Array]
stereo.samples;        // the first channel

Leaving channelMode alone (or setting it to "mono") downmixes before enhancement, so the model runs once:

await clear.enhance([left, right], 48_000);   // one channel out, one inference pass

Mastering is joint: one loudness gain and one limiter envelope across the channels, so it never moves the stereo image. balanceChannelsLUFS is the deliberate exception, for a pair whose sides were recorded at different levels:

await clear.enhance([left, right], 48_000,
                    { channelMode: "preserve", balanceChannelsLUFS: -20 });

Mastering

By default the output is normalized to the Apple Podcasts target (-19 LUFS) with a -1.5 dBTP ceiling, held by a look-ahead limiter rather than by turning the whole file down to fit its loudest transient.

await clear.enhance(samples, 48_000, { targetLUFS: "spotify" });   // -14 LUFS
await clear.enhance(samples, 48_000, { targetLUFS: -23 });         // an explicit target
await clear.enhance(samples, 48_000, { targetLUFS: null });        // skip mastering

LOUDNESS_PRESETS carries the published platform targets (applePodcasts, spotify, youtube, broadcast). Two more knobs are available: peakCeilingDBFS (default -1.5) and maxGainDB (default 9), which bounds how far a very quiet input is lifted so the model's noise floor does not come up with it.

strength blends the enhanced signal against the original, for when full denoising sounds too processed:

await clear.enhance(samples, 48_000, { strength: 0.7 });

outputSampleRate sets the delivery rate. The model always runs at 48 kHz and the result is resampled on the way out, so the meter and the limiter still see the rate their constants are derived for:

await clear.enhance(samples, 48_000, { outputSampleRate: 44_100 });

Self-hosting and progress

const clear = await Clear.load({
  modelBaseUrl: "/assets/clear/",     // browser: serve the files yourself
  directory: "/var/cache/clear",      // Node: adopt or download here
  onProgress: (fraction) => console.log(fraction),
});

The model repo and revision are pinned to this SDK version, so an install is reproducible. Weights live on Hugging Face.

License

Desert Ant Labs Source-Available License. Free for most apps, and a commercial license is required at scale. Full terms are at the link. Licensing: [email protected].

Third-party notices for the SDK: THIRD_PARTY_NOTICES.md.

Third-party notices for the weights: THIRD_PARTY_NOTICES.md.

版本与发布记录

@desert-ant-labs/clear 共发布 22 个版本,首次发布于 2026/06/30;过去 12 个月发布了 22 个版本。

版本发布日期距今
4.3.0latest2026/11/066 天前
4.2.32026/10/3112 天前
4.2.22026/10/3112 天前
4.2.12026/10/2815 天前
4.2.02026/10/2716 天前
4.1.02026/10/2023 天前

关于 @desert-ant-labs/clear 的常见问题

@desert-ant-labs/clear 是什么?

On-device speech enhancement for JavaScript: denoise, dereverb, and loudness-normalize to a podcast-ready 48 kHz. Runs in the browser (WebAssembly + LiteRT.js) and server-side in Node (native), from one import.

如何安装 @desert-ant-labs/clear?

在项目目录运行 npm install @desert-ant-labs/clear,或使用 pnpm add / yarn add / bun add。

@desert-ant-labs/clear 支持 TypeScript 吗?

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

@desert-ant-labs/clear 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@desert-ant-labs/clear 可以商用吗?

@desert-ant-labs/clear 使用 SEE LICENSE IN LICENSE.md 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@desert-ant-labs/clear 的下载量有多少?

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

@desert-ant-labs/clear 还在维护吗?

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