diff --git a/package.json b/package.json index 8be8687..276b565 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@picovoice/web-voice-processor", - "version": "4.0.8", + "version": "4.0.9", "description": "Real-time audio processing for voice, in web browsers", "entry": "src/index.ts", "module": "dist/esm/index.js", diff --git a/src/types.ts b/src/types.ts index 6eb8e2f..3cd6013 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ /* - Copyright 2018-2022 Picovoice Inc. + Copyright 2018-2024 Picovoice Inc. You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. @@ -36,7 +36,9 @@ export type WebVoiceProcessorOptions = { /** Microphone id to use (can be fetched with mediaDevices.enumerateDevices) */ deviceId?: string | null; /** Filter order (default: 50) */ - filterOrder?: number + filterOrder?: number; + /** Custom made recorder processor */ + customRecorderProcessorURL?: string; }; export type ResamplerWorkerInitRequest = { diff --git a/src/web_voice_processor.ts b/src/web_voice_processor.ts index 6cfd7cc..23ee58b 100644 --- a/src/web_voice_processor.ts +++ b/src/web_voice_processor.ts @@ -298,8 +298,12 @@ export class WebVoiceProcessor { private async getAudioContext(): Promise { if (this._audioContext === null || this.isReleased) { this._audioContext = new AudioContext(); - const objectURL = URL.createObjectURL(new Blob([base64ToUint8Array(recorderProcessor).buffer], {type: 'application/javascript'})); - await this._audioContext.audioWorklet.addModule(objectURL); + if (this._options.customRecorderProcessorURL) { + await this._audioContext.audioWorklet.addModule(this._options.customRecorderProcessorURL); + } else { + const objectURL = URL.createObjectURL(new Blob([base64ToUint8Array(recorderProcessor).buffer], {type: 'application/javascript'})); + await this._audioContext.audioWorklet.addModule(objectURL); + } } return this._audioContext; }