Skip to content

Commit

Permalink
Merge pull request #61 from Picovoice/wvp-custom-processor
Browse files Browse the repository at this point in the history
add method to add custom processor URL
  • Loading branch information
ErisMik authored Mar 15, 2024
2 parents 86b8426 + 8138463 commit 289e5b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 = {
Expand Down
8 changes: 6 additions & 2 deletions src/web_voice_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,12 @@ export class WebVoiceProcessor {
private async getAudioContext(): Promise<AudioContext> {
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;
}
Expand Down

0 comments on commit 289e5b8

Please sign in to comment.