Utility for audio
$ npm install the-audio-util --save
'use strict'
const {rmsFor} = require('the-audio-util')
async function tryExample () {
class SpeechAudioProcessor extends AudioWorkletProcessor {
process (inputs, outputs) {
const input = inputs[0]
const output = outputs[0]
for (let channel = 0; channel < output.length; ++channel) {
output[channel].set(input[channel])
{
const rms = rmsFor(input[channel])
this.port.postMessage({rms})
}
}
return true
}
}
}
tryExample().catch((err) => console.error(err))
This software is released under the MIT License.