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;
}