encode a AudioData
frame from WebCodecs API to PCM
format
NPM Package
https://www.npmjs.com/package/audiodata2pcm
CDN URL
<script src="https://unpkg.com/audiodata2pcm@0.1.0/dist/audiodata2pcm.js"></script>
PCM Signed 16-bit 16kHz
as an Int16Array
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const trackProcessor = new MediaStreamTrackProcessor({
track: stream.getAudioTracks()[0],
});
trackProcessor.readable.pipeTo(
new WritableStream({
write: async (frame) => {
const data = audiodata2pcm(frame);
// ...
},
close() {
console.log(`track processor closed`);
},
})
);
GUO YANKE, MIT License