Migration
1.x 에서 2.x 로 마이그레이션
딥히어링 Denoise SDK for Javascript Wiki 입니다.
AI 노이즈 제거 솔루션의 상세 정보 및 변경 사항 등을 확인할 수 있습니다.
Load Module
WebAssembly로 빌드된 dh_module.js
와 AudioWorklet 관련 파일을 함께 번들링 하는 방식으로 변경 되었습니다.
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
기존 init()
함수를 초기화 하는 방식에서, 모듈 로드시 자동으로 초기화가 되도록 변경되었습니다.
V1.x
init();
V2.x
console 출력
[Deep Hearing] workletNode created
Audio Constraints
딥히어링 노이즈 제거 SDK를 사용할 때 권장되는 Audio Contraints를 얻을 수 있는 함수가 추가되었습니다.
V1.x
const constraints = { audio: { autoGainControl: false, echoCancellation: false, noiseSuppression: false, },};
V2.x
denoise.getConstraints();
Append Denoise AudioWorklet Node to Stream
AudioWorklet 관련 소스가 함께 번들링이 되어 AudioWorkletNode로 새로운 Node를 직접 생성하지 않습니다.
appendDenoiserToStream
함수를 이용해 stream에 denoise worklet node를 연결 할 수 있습니다.
샘플레이트가 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
더 이상 AudioWorkletNode 의 파라미터를 통해 직접 on/off를 설정하지 않습니다.
setDenoiseState
함수를 통해 denoise를 on/off 할 수 있습니다.
V1.x
//...paramDenoise = dhWorkletNode.parameters.get('denoise');//...paramDenoise.setValueAtTime(Number(isDenoiseOn), 0);
V2.x
denoise.setDenoiseState(true / false);