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

feat(noise-suppression): Add support for BVC model #15163

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,17 @@ var config = {
// - https://meet.example.com/libs/krisp/models/model_8.kw
// - https://meet.example.com/libs/krisp/models/model_16.kw
// - https://meet.example.com/libs/krisp/models/model_32.kw
// - https://meet.example.com/libs/krisp/models/model_bvc.kw
// - https://meet.example.com/libs/krisp/assets/bvc-allowed.txt
// In case when you have known BVC supported devices and you want to extend allowed devices list
// - https://meet.example.com/libs/krisp/assets/bvc-allowed-ext.txt
// NOTE: Krisp JS SDK v1.0.9 was tested.
// noiseSuppression: {
// krisp: {
// enabled: false,
// logProcessStats: false,
// debugLogs: false,
// useBVC: false,
// },
// },

Expand Down
1 change: 1 addition & 0 deletions react/features/base/config/configType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export interface INoiseSuppressionConfig {
debugLogs?: boolean;
enabled?: boolean;
logProcessStats?: boolean;
useBVC?: boolean;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class NoiseSuppressionEffect {
let init;

if (this._options?.krisp?.enabled) {
init = _initializeKrisp(this._options).then(filterNode => {
init = _initializeKrisp(this._options, audioStream).then(filterNode => {
this._noiseSuppressorNode = filterNode;

if (krispState.filterNodeReady) {
Expand Down Expand Up @@ -167,10 +167,14 @@ export class NoiseSuppressionEffect {
* Initializes the Krisp SDK and creates the filter node.
*
* @param {INoiseSuppressionConfig} options - Krisp options.
* @param {MediaStream} stream - Audio stream which will be mixed with _mixAudio.
*
* @returns {Promise<AudioWorkletNode | undefined>}
*/
async function _initializeKrisp(options: INoiseSuppressionConfig): Promise<AudioWorkletNode | undefined> {
async function _initializeKrisp(
options: INoiseSuppressionConfig,
stream: MediaStream
): Promise<AudioWorkletNode | undefined> {
await audioContext.resume();

if (!krispState.sdk) {
Expand All @@ -180,12 +184,18 @@ async function _initializeKrisp(options: INoiseSuppressionConfig): Promise<Audio
krispState.sdk = new KrispSDK({
params: {
models: {
modelBVC: `${baseUrl}/models/model_bvc.kw`,
model8: `${baseUrl}/models/model_8.kw`,
model16: `${baseUrl}/models/model_16.kw`,
model32: `${baseUrl}/models/model_32.kw`
},
logProcessStats: options?.krisp?.logProcessStats,
debugLogs: options?.krisp?.debugLogs
debugLogs: options?.krisp?.debugLogs,
useBVC: options?.krisp?.useBVC,
bvc: {
allowedDevices: `${baseUrl}/assets/bvc-allowed.txt`,
allowedDevicesExt: `${baseUrl}/assets/bvc-allowed-ext.txt`
}
},
callbacks: {}
});
Expand All @@ -201,14 +211,20 @@ async function _initializeKrisp(options: INoiseSuppressionConfig): Promise<Audio
if (!krispState.filterNode) {
try {
// @ts-ignore
krispState.filterNode = await krispState.sdk?.createNoiseFilter(audioContext, () => {
logger.info('Krisp audio filter ready');
krispState.filterNode = await krispState.sdk?.createNoiseFilter(
{
audioContext,
stream
},
() => {
logger.info('Krisp audio filter ready');

// Enable audio filtering.
// @ts-ignore
krispState.filterNode?.enable();
krispState.filterNodeReady = true;
});
// Enable audio filtering.
// @ts-ignore
krispState.filterNode?.enable();
krispState.filterNodeReady = true;
}
);
} catch (e) {
logger.error('Failed to create Krisp noise filter', e);

Expand Down