Skip to main content

Migration

Migration to 2.x from 1.x

Welcome

This is Deep Hearing Denoise SDK for Javascript Wiki.

You can check the details and changes of the AI denoising solution, and more.

Load Module

It has been changed to bundling dh_module.js built with WebAssembly and AudioWorklet related files together.

V1.x


<script src="dh_module.js"></script>


const dhModule = {
denoise: Module.cwrap('speech_enhancement', '', ['number', 'number']),
init: Module.cwrap('init', '', []),
del: Module.cwrap('delete', '', []),
create_buffer: Module.cwrap('create_buffer', 'number', ['number']),
destroy_buffer: Module.cwrap('destroy_buffer', '', ['number']),
};

V2.x


<script src="dh-denoise.js"></script>


const denoise = window.DeepHearing.Denoise;

Initialize Module

The method of initializing the existing init() function has been changed so that it is automatically initialized when the module is loaded.

V1.x


init();

V2.x
console output


[Deep Hearing] workletNode created

Audio Constraints

Added a function to get the recommended Audio Constraints when using the Deep Hearing Denoise SDK.

V1.x


const constraints = {
audio: {
autoGainControl: false,
echoCancellation: false,
noiseSuppression: false,
},
};

V2.x


denoise.getConstraints();

Append Denoise AudioWorklet Node to Stream

AudioWorklet-related sources are bundled together, so that a new AudioWorkletNode is not directly created.
You can attach a denoise worklet node to a stream using the appendDenoiserToStream function.

The sample rate has been changed to fixed at ‘48KHz’.
V1.x


navigator.mediaDevices.getUserMedia(audioConstraints).then((stream) => {
audioContext.audioWorklet
.addModule('js/wasm-worklet-processor.js')
.then(() => {
dhWorkletNode = new AudioWorkletNode(
audioContext,
'wasm-worklet-processor',
{
processorOptions: {
sampleRate: audioContext.sampleRate,
},
},
);
source.connect(dhWorkletNode).connect(processedStream);
paramDenoise = dhWorkletNode.parameters.get('denoise');
});
});

V2.x


const processorPath = './dh-denoise-processor.js';
const audioConstraints = denoise.getConstraints();
const stream = await navigator.mediaDevices.getUserMedia(audioConstraints);
const streamWithDenoiser = await denoise.appendDenoiserToStream(
stream,
processorPath,
);

Denoise On/Off

No longer set on/off directly via parameters of AudioWorkletNode.
You can turn denoise on/off through setDenoiseState function.
V1.x


//...
paramDenoise = dhWorkletNode.parameters.get('denoise');
//...
paramDenoise.setValueAtTime(Number(isDenoiseOn), 0);

V2.x


denoise.setDenoiseState(true / false);