Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add method to add custom processor URL #61

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,13 +298,17 @@
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;
}

private async setupRecorder(

Check warning on line 311 in src/web_voice_processor.ts

View workflow job for this annotation

GitHub Actions / check-web-codestyle

Missing return type on function
options: WebVoiceProcessorOptions,
) {
if (navigator.mediaDevices === undefined) {
Expand Down
Loading