Made in Vancouver, Canada by Picovoice
This is a library for real-time voice processing in web browsers.
- Uses Worker to offload compute-intensive work to background threads.
- Converts the microphone sampling rate to 16000 which is used by (almost all) voice processing engines.
- Provides a flexible interface to pass in arbitrary voice processing workers.
The library makes use of Web Audio API, which is supported on all modern browsers except Internet Explorer.
npm install web-voice-processor
Add the following to your HTML
<script src="{PATH_TO_WEB_VOICE_PROCESSOR_JS}"></script>
Replace {PATH_TO_WEB_VOICE_PROCESSOR_JS}
with the path to src/web_voice_processor.js.
The library adds WebVoiceProcessor
as a singleton to the global scope.
Start processing
window.WebVoiceProcessor.start(engines, downsamplerScript, errorCallback)
engines
is a list of voice processing Workers
implementing the following interface within their onmessage
method
onmessage = function (e) {
switch (e.data.command) {
...
case 'process':
process(e.data.inputFrame);
break;
...
}
};
where e.data.inputFrame
is an Int16Array
of 512 audio samples.
downsamplerScript
is the path to downsampling_worker.js relative to HTML file.
The errorCallback
is executed if audio acquisition fails.
Stop processing
window.WebVoiceProcessor.stop()