Download assets/js/pcm-processor.js from headway/medicode: direct link, hf CLI and curl.
- Browser
- Download file 701 Bytes
-
https://huggingface.co/spaces/headway/medicode/resolve/main/assets/js/pcm-processor.js
- Command line
-
hf download hf://spaces/headway/medicode/assets/js/pcm-processor.js
-
curl -L -o pcm-processor.js https://huggingface.co/spaces/headway/medicode/resolve/main/assets/js/pcm-processor.js
701 Bytes
| class PCMProcessor extends AudioWorkletProcessor { | |
| constructor(options) { | |
| super(); | |
| this.sampleBuffer = []; | |
| this.chunkSize = options.processorOptions.chunkSize || 16_000; | |
| } | |
| process(inputs) { | |
| const input = inputs[0]; | |
| if (input.length > 0) { | |
| const inputData = input[0]; | |
| for (let i = 0; i < inputData.length; ++i) { | |
| this.sampleBuffer.push(inputData[i]); | |
| if (this.sampleBuffer.length >= this.chunkSize) { | |
| this.port.postMessage(this.sampleBuffer.slice(0, this.chunkSize)); | |
| this.sampleBuffer = this.sampleBuffer.slice(this.chunkSize); | |
| } | |
| } | |
| } | |
| return true; | |
| } | |
| } | |
| registerProcessor("pcm-processor", PCMProcessor); | |