Skip to content

Commit

Permalink
feat(ns) update Krisp to latest version
Browse files Browse the repository at this point in the history
* feat(noise-suppression): Add support for BVC model

* feat(noise-suppression): Add support for extended BVC devices list

This commit adds support for extending the list of allowed BVC devices in the noise suppression feature. It introduces a new file, `bvc-allowed-ext.txt`, which can be used to include additional BVC supported devices.

* fix(noise-suppression): reuse the existing audioStream for Krisp initialization

* update krisp configuration

* refactor(krisp): Update Krisp JS SDK version and noise suppression configuration

* refactor(config): update config default values, add the enabled flad in INoiseSuppressionConfig
  • Loading branch information
aashot authored Nov 13, 2024
1 parent 86d1bd3 commit 49cf632
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 22 deletions.
37 changes: 34 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,45 @@ var config = {
// installation. Specifically, these files are needed:
// - https://meet.example.com/libs/krisp/krisp.mjs
// - 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
// NOTE: Krisp JS SDK v1.0.9 was tested.
// - https://meet.example.com/libs/krisp/models/model_nc.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
// In case when you have known BVC supported devices and you want to extend allowed devices list
// - https://meet.example.com/libs/krisp/models/model_inbound_8.kw
// - https://meet.example.com/libs/krisp/models/model_inbound_16.kw
// In case when you want to use inbound noise suppression models
// NOTE: Krisp JS SDK v2.0.0 was tested.
// noiseSuppression: {
// krisp: {
// enabled: false,
// logProcessStats: false,
// debugLogs: false,
// useBVC: false,
// bufferOverflowMS: 1000,
// inboundModels: {
// modelInbound8: 'model_inbound_8.kef',
// modelInbound16: 'model_inbound_16.kef',
// },
// preloadInboundModels: {
// modelInbound8: 'model_inbound_8.kef',
// modelInbound16: 'model_inbound_16.kef',
// },
// preloadModels: {
// modelBVC: 'model_bvc.kef',
// model8: 'model_8.kef',
// modelNC: 'model_nc_mq.kef',
// },
// models: {
// modelBVC: 'model_bvc.kef',
// model8: 'model_8.kef',
// modelNV: 'model_nc_mq.kef',
// },
// bvc: {
// allowedDevices: 'bvc-allowed.txt',
// allowedDevicesExt: 'bvc-allowed-ext.txt',
// }
// },
// },

Expand Down
20 changes: 18 additions & 2 deletions react/features/base/config/configType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,27 @@ export interface IDeeplinkingConfig {
ios?: IDeeplinkingMobileConfig;
}

export type PartialRecord<K extends keyof any, T> = {
[P in K]?: T;
};

export interface INoiseSuppressionConfig {
krisp?: {
debugLogs?: boolean;
enabled?: boolean;
bufferOverflowMS?: number;
bvc?: {
allowedDevices?: string;
allowedDevicesExt?: string;
};
debugLogs: boolean;
enableSessionStats?: boolean;
enabled: boolean;
inboundModels?: PartialRecord<string, string>;
logProcessStats?: boolean;
models?: PartialRecord<string, string>;
preloadInboundModels?: PartialRecord<string, string>;
preloadModels?: PartialRecord<string, string>;
useBVC?: boolean;
useSharedArrayBuffer?: 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,26 +167,52 @@ 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) {
const baseUrl = `${getBaseUrl()}libs/krisp`;
const { default: KrispSDK } = await import(/* webpackIgnore: true */ `${baseUrl}/krispsdk.mjs`);

krispState.sdk = new KrispSDK({
params: {
const ncParams = {
krisp: {
models: {
model8: `${baseUrl}/models/model_8.kw`,
model16: `${baseUrl}/models/model_16.kw`,
model32: `${baseUrl}/models/model_32.kw`
modelBVC: `${baseUrl}/models/${options?.krisp?.models?.modelBVC}`,
model8: `${baseUrl}/models/${options?.krisp?.models?.model8}`,
modelNC: `${baseUrl}/models/${options?.krisp?.models?.modelNC}`
},
logProcessStats: !options?.krisp?.logProcessStats,
debugLogs: !options?.krisp?.debugLogs,
useBVC: !options?.krisp?.useBVC,
bvc: {
allowedDevices: `${baseUrl}/assets/${options?.krisp?.bvc?.allowedDevices}`,
allowedDevicesExt: `${baseUrl}/assets/${options?.krisp?.bvc?.allowedDevicesExt}`
},
inboundModels: {
modelInbound8: `${baseUrl}/models/${options?.krisp?.inboundModels?.modelInbound8}`,
modelInbound16: `${baseUrl}/models/${options?.krisp?.inboundModels?.modelInbound16}`
},
preloadModels: {
modelBVC: `${baseUrl}/models/${options?.krisp?.preloadModels?.modelBVC}`,
model8: `${baseUrl}/models/${options?.krisp?.preloadModels?.model8}`,
modelNC: `${baseUrl}/models/${options?.krisp?.preloadModels?.modelNC}`
},
logProcessStats: options?.krisp?.logProcessStats,
debugLogs: options?.krisp?.debugLogs
},
preloadInboundModels: {
modelInbound8: `${baseUrl}/models/${options?.krisp?.preloadInboundModels?.modelInbound8}`,
modelInbound16: `${baseUrl}/models/${options?.krisp?.preloadInboundModels?.modelInbound16}`
}
}
};

krispState.sdk = new KrispSDK({
params: ncParams.krisp,
callbacks: {}
});
}
Expand All @@ -201,14 +227,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

0 comments on commit 49cf632

Please sign in to comment.