JSPM

pcm-s16le-recorder

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q22201F
  • License MIT

Pure browser PCM S16LE audio recorder via AudioWorklet for ASR (no MediaRecorder, no Opus).

Package Exports

  • pcm-s16le-recorder

Readme

pcm-s16le-recorder

Чистый браузерный PCM S16LE рекордер (AudioWorklet → Float32 → Int16 LE) для ASR.
Без MediaRecorder/Opus, только сырые PCM чанки.

Установка

npm i pcm-s16le-recorder

или

yarn add pcm-s16le-recorder

Быстрый старт (React)

import { useEffect } from "react";
import { createPcmRecorder, buildPcmContentType, pcmInt16ToUint8View } from "pcm-s16le-recorder";

export function Mic() {
  useEffect(() => {
    const rec = createPcmRecorder({
      targetSampleRate: 16000,
      targetChunkFrames: 16000 * 0.25, // ~250ms
      onChunk: (chunk) => {
        const bytes = pcmInt16ToUint8View(chunk.data);
        // пример HTTP
        fetch("/asr/stream", {
          method: "POST",
          headers: { "Content-Type": buildPcmContentType(chunk.sampleRate) },
          body: bytes
        });
      }
    });

    (async () => {
      await rec.start();
    })();

    return () => {
      rec.stop();
    };
  }, []);

  return null;
}