{"id":14007035,"url":"https://github.com/Picovoice/web-voice-processor","last_synced_at":"2025-07-24T00:33:01.514Z","repository":{"id":35007131,"uuid":"195894290","full_name":"Picovoice/web-voice-processor","owner":"Picovoice","description":"A library for real-time voice processing in web browsers","archived":false,"fork":false,"pushed_at":"2024-03-16T14:31:12.000Z","size":2648,"stargazers_count":166,"open_issues_count":0,"forks_count":18,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-14T07:59:15.422Z","etag":null,"topics":["audio-processing","browser","downsampling","javascript","microphone","pcm","real-time","realtime","speech-recognition","speech-to-text","voice-commands","voice-processing","wake-word-detection","web-browser","webaudio-api","worker"],"latest_commit_sha":null,"homepage":"https://picovoice.ai/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Picovoice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-07-08T22:28:40.000Z","updated_at":"2024-04-10T16:12:35.000Z","dependencies_parsed_at":"2024-01-20T00:28:50.742Z","dependency_job_id":"29fc8c4a-5c1a-4aee-a5e5-2ff4242a1bf3","html_url":"https://github.com/Picovoice/web-voice-processor","commit_stats":{"total_commits":123,"total_committers":8,"mean_commits":15.375,"dds":0.6016260162601625,"last_synced_commit":"86b8426e5d7a6e400be8b74ac5ad400d161dd6c0"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Picovoice%2Fweb-voice-processor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Picovoice%2Fweb-voice-processor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Picovoice%2Fweb-voice-processor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Picovoice%2Fweb-voice-processor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Picovoice","download_url":"https://codeload.github.com/Picovoice/web-voice-processor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":214780404,"owners_count":15783765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio-processing","browser","downsampling","javascript","microphone","pcm","real-time","realtime","speech-recognition","speech-to-text","voice-commands","voice-processing","wake-word-detection","web-browser","webaudio-api","worker"],"created_at":"2024-08-10T10:01:46.907Z","updated_at":"2024-08-10T10:03:41.374Z","avatar_url":"https://github.com/Picovoice.png","language":"TypeScript","readme":"# Web Voice Processor\n\n[![GitHub release](https://img.shields.io/github/release/Picovoice/web-voice-processor.svg)](https://github.com/Picovoice/web-voice-processor/releases)\n[![GitHub](https://img.shields.io/github/license/Picovoice/web-voice-processor)](https://github.com/Picovoice/web-voice-processor/releases)\n[![npm](https://img.shields.io/npm/v/@picovoice/web-voice-processor?label=npm%20%5Bweb%5D)](https://www.npmjs.com/package/@picovoice/web-voice-processor)\n\nMade in Vancouver, Canada by [Picovoice](https://picovoice.ai)\n\nA library for real-time voice processing in web browsers.\n\n- Uses the [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) to access microphone audio.\n- Leverages [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Worker) to offload compute-intensive tasks off of the main thread.\n- Converts the microphone sampling rate to 16kHz, the _de facto_ standard for voice processing engines.\n- Provides a flexible interface to pass in arbitrary voice processing workers.\n\n- [Web Voice Processor](#web-voice-processor)\n  - [Browser compatibility](#browser-compatibility)\n    - [Browser features](#browser-features)\n  - [Installation](#installation)\n  - [How to use](#how-to-use)\n    - [Via ES Modules (Create React App, Angular, Webpack, etc.)](#via-es-modules-create-react-app-angular-webpack-etc)\n    - [Via HTML script tag](#via-html-script-tag)\n    - [Start listening](#start-listening)\n    - [Stop listening](#stop-listening)\n  - [Build from source](#build-from-source)\n\n## Browser compatibility\n\nAll modern browsers (Chrome/Edge/Opera, Firefox, Safari) are supported, including on mobile. Internet Explorer is _not_ supported.\n\nUsing the Web Audio API requires a secure context (HTTPS connection), with the exception of `localhost`, for local development.\n\nThis library includes the utility function `browserCompatibilityCheck` which can be used to perform feature detection on the current browser and return an object\nindicating browser capabilities.\n\nESM:\n\n```javascript\nimport { browserCompatibilityCheck } from '@picovoice/web-voice-processor';\nbrowserCompatibilityCheck();\n```\n\nIIFE:\n\n```javascript\nwindow.WebVoiceProcessor.browserCompatibilityCheck();\n```\n\n### Browser features\n\n- '\\_picovoice' : whether all Picovoice requirements are met\n- 'AudioWorklet' (not currently used; intended for the future)\n- 'isSecureContext' (required for microphone permission for non-localhost)\n- 'mediaDevices' (basis for microphone enumeration / access)\n- 'WebAssembly' (required for all Picovoice engines)\n- 'webKitGetUserMedia' (legacy predecessor to getUserMedia)\n- 'Worker' (required for resampler and for all engine processing)\n\n## Installation\n\n```console\nnpm install @picovoice/web-voice-processor\n```\n\n(or)\n\n```console\nyarn add @picovoice/web-voice-processor\n```\n\n## How to use\n\n### Via ES Modules (Create React App, Angular, Webpack, etc.)\n\n```javascript\nimport { WebVoiceProcessor } from '@picovoice/web-voice-processor';\n```\n\n### Via HTML script tag\n\nAdd the following to your HTML:\n\n```html\n\u003cscript src=\"@picovoice/web-voice-processor/dist/iife/index.js\"\u003e\u003c/script\u003e\n```\n\nThe IIFE version of the library adds `WebVoiceProcessor` to the `window` global scope.\n\n### Start listening\n\nWebVoiceProcessor follows the subscribe/unsubscribe pattern. WebVoiceProcessor\nwill automatically start recording audio as soon as an engine is subscribed.\n\n```javascript\nconst worker = new Worker('${WORKER_PATH}');\nconst engine = {\n  onmessage: function(e) {\n    /// ... handle inputFrame\n  }\n}\n\nawait WebVoiceProcessor.subscribe(engine);\nawait WebVoiceProcessor.subscribe(worker);\n// or\nawait WebVoiceProcessor.subscribe([engine, worker]);\n```\n\nAn `engine` is either a [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Worker) or an object\nimplementing the following interface within their `onmessage` method:\n\n```javascript\nonmessage = function (e) {\n    switch (e.data.command) {\n        case 'process':\n            process(e.data.inputFrame);\n            break;\n    }\n};\n```\n\nwhere `e.data.inputFrame` is an `Int16Array` of `frameLength` audio samples.\n\nFor examples of using engines, look at [src/engines](src/engines).\n\nThis is async due to its [Web Audio API microphone request](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia). The promise will be rejected if the user refuses permission, no suitable devices are found, etc. Your calling code should anticipate the possibility of rejection. When the promise resolves, the WebVoiceProcessor is running.\n\n### Stop Listening\n\nUnsubscribing the engines initially subscribed will stop audio recorder.\n\n```javascript\nawait WebVoiceProcessor.unsubscribe(engine);\nawait WebVoiceProcessor.unsubscribe(worker);\n//or\nawait WebVoiceProcessor.unsubscribe([engine, worker]);\n```\n\n### Reset\n\nUse the `reset` function to remove all engines and stop recording audio.\n\n```javascript\nawait WebVoiceProcessor.reset();\n```\n\n### Options\n\nTo update the audio settings in `WebVoiceProcessor`, use the `setOptions` function:\n\n```javascript\n// Override default options\nlet options = {\n  frameLength: 512,\n  outputSampleRate: 16000,\n  deviceId: null,\n  filterOrder: 50,\n};\n\nWebVoiceProcessor.setOptions(options);\n```\n\n### Custom Recorder Processor\n\n**NOTE**: Issues related to custom recorder processor implementations are out of the scope of this repo.\n\nTake a look at [recorder_processor.js](src/audio_worklet/recorder_processor.js) in this repo as a reference\non how to create a simple recorder processor. To learn more about creating a recorder processor,\ncheck out [AudioWorkletProcessor](https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletProcessor) docs.\n\nAdd the option `customRecorderProcessorURL` to options object to use your own recorder processor.\nEnter the string to the custom recorder processor URL or leave it blank to use the default recorder processor.\n\n```javascript\n// Override default options\nlet options = {\n  frameLength: 512,\n  outputSampleRate: 16000,\n  deviceId: null,\n  filterOrder: 50,\n  customRecorderProcessorURL: \"${URL_PATH_TO_RECORDER_PROCESSOR}\"\n};\n\nWebVoiceProcessor.setOptions(options);\n```\n\n### VuMeter\n\n`WebVoiceProcessor` includes a built-in engine which returns the [VU meter](https://en.wikipedia.org/wiki/VU_meter).\nTo capture the VU meter value, create a VuMeterEngine instance and subscribe it to the engine:\n\n```javascript\nfunction vuMeterCallback(dB) {\n  console.log(dB)\n}\n\nconst vuMeterEngine = new VuMeterEngine(vuMeterCallback);\nWebVoiceProcessor.subscribe(vuMeterEngine);\n```\n\nThe `vuMeterCallback` should expected a number in terms of [dBFS](https://en.wikipedia.org/wiki/DBFS) within the range of [-96, 0].\n\n## Build from source\n\nUse `yarn` or `npm` to build WebVoiceProcessor:\n\n```console\nyarn\nyarn build\n```\n\n(or)\n\n```console\nnpm install\nnpm run-script build\n```\n\nThe build script outputs minified and non-minified versions of the IIFE and ESM formats to the `dist` folder. It also will output the TypeScript type definitions.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPicovoice%2Fweb-voice-processor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPicovoice%2Fweb-voice-processor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPicovoice%2Fweb-voice-processor/lists"}