npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dannadori/audio-recorder-js

v0.0.16

Published

`@dannadori/audio-recorder-js`は、Web Audio API を活用した高性能なオーディオ録音・処理ライブラリです。AudioWorklet を使用したリアルタイム処理により、低遅延で高品質なオーディオ処理を実現します。

Readme

@dannadori/audio-recorder-js

概要

@dannadori/audio-recorder-jsは、Web Audio API を活用した高性能なオーディオ録音・処理ライブラリです。AudioWorklet を使用したリアルタイム処理により、低遅延で高品質なオーディオ処理を実現します。

主な特徴:

  • Web Audio API と AudioWorklet による高性能なオーディオ処理
  • 高度なノイズサプレッション エコーキャンセレーション機能
  • オーディオ入力/出力/モニターのゲイン調整
  • オーディオデータのコールバック処理による柔軟なカスタマイズ

インストール

npm install @dannadori/audio-recorder-js
# または
yarn add @dannadori/audio-recorder-js
# または
pnpm add @dannadori/audio-recorder-js

基本的な使い方

直接 AudioRecorder クラスを使用する例

import { AudioRecorder, AudioDataCallback } from "@dannadori/audio-recorder-js";

// AudioContextの作成
const audioContext = new AudioContext();

// AudioRecorderの初期化(第2引数はVoice Focus有効化フラグ)
const audioRecorder = new AudioRecorder(audioContext, true);

// 初期化の完了を待機
await audioRecorder.isInitialized();

// オーディオデータのコールバック設定
const audioDataCallback: AudioDataCallback = {
    // オーディオデータを受信したときのコールバック
    onAudioReceived: async (data: Float32Array) => {
        console.log("オーディオデータ受信:", data.length);
    },

    // オーディオデータを処理するコールバック(加工したデータを返す)
    processAudio: async (data: Float32Array) => {
        // ここでデータを加工できます
        return data; // 加工したデータを返す
    },
};

audioRecorder.setAudioDataCallback(audioDataCallback);

// 設定の更新
audioRecorder.updateSettings({
    audioRecorderSetting: {
        audioInput: "default", // デバイスIDまたはMediaStream
        sampleRate: 48000,
        echoCancel: true,
        noiseSuppression: true,
        noiseSuppression2: true, // Voice Focus使用
        inputGain: 1.0,
        outputGain: 1.0,
        monitorGain: 0.5,
        passThroughConfirmationSkip: false,
    },
    workletNodeSetting: {
        serverUrl: "",
        protocol: "rest",
        sendingSampleRate: 48000,
        sendingChunkSec: 0.2,
        sendingChunkAsBulk: false,
        enableFlatPath: false,
        workOnColab: false,
    },
    workletSetting: {
        numTruncateThreshold: 100,
        outputBufferFactor: 5,
    },
});

// 録音開始
await audioRecorder.start();

// 録音停止
await audioRecorder.stop();

// 出力ストリームの取得
const outputStream = audioRecorder.stream;

// モニターストリームの取得
const monitorStream = audioRecorder.monitorStream;

主な機能と設定オプション

オーディオ入力設定

  • audioInput: マイクのデバイス ID または MediaStream オブジェクト
  • sampleRate: サンプルレート(デフォルト: 48000Hz)
  • echoCancel: エコーキャンセレーション有効/無効
  • noiseSuppression: ブラウザ標準のノイズサプレッション有効/無効
  • noiseSuppression2: Amazon Chime SDK の Voice Focus 有効/無効

ゲイン設定

  • inputGain: 入力ゲイン(0.0〜1.0)
  • outputGain: 出力ゲイン(0.0〜1.0)
  • monitorGain: モニターゲイン(0.0〜1.0)

Worklet 設定

  • numTruncateThreshold: バッファ切り詰めの閾値
  • outputBufferFactor: 出力バッファサイズの係数

オーディオデータコールバック

オーディオデータを処理するためのコールバック関数を設定できます:

setAudioDataCallback({
    // オーディオデータを受信したときのコールバック
    onAudioReceived: async (data: Float32Array) => {
        // データを受信したときの処理
    },

    // オーディオデータを処理するコールバック
    processAudio: async (data: Float32Array) => {
        // データを加工して返す
        return processedData;
    },
});

注意事項

  • AudioWorklet を使用するため、最新のブラウザが必要です
  • ブラウザのセキュリティ制限により、HTTPS 環境または localhost 環境での実行が推奨されます
  • マイクへのアクセス許可が必要です

ライセンス

このライブラリはMIT ライセンスの下で公開されています。