繁体   English   中英

如何使用Web Audio API降低麦克风输入的噪音?

[英]How can I reduce the noise of a microphone input with the Web Audio API?

我一直在使用Web Audio API,并使用笔记本电脑的麦克风作为输入源。 但是,当我听输入时,我会听到很多白噪声。 如何创建滤波器以减少噪音,使声音更清晰? 是否有任何库可以针对这种情况提供预写的噪声滤波器?

使用BiquadFilter可以在某些POC上工作,并减少笔记本电脑的使用寿命。 我也使用过压缩机,但您不必))

(function(){
    var filter, compressor, mediaStreamSource;

    // Start off by initializing a new context.
    var context = new (window.AudioContext || window.webkitAudioContext)();


    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia;
    navigator.getUserMedia( {audio:true}, initAudio , function(err){
        console.log('usermedia error', err)
    });



    function initAudio(stream) {
        compressor = context.createDynamicsCompressor();
        compressor.threshold.value = -50;
        compressor.knee.value = 40;
        compressor.ratio.value = 12;
        compressor.reduction.value = -20;
        compressor.attack.value = 0;
        compressor.release.value = 0.25;

        filter = context.createBiquadFilter();
        filter.Q.value = 8.30;
        filter.frequency.value = 355;
        filter.gain.value = 3.0;
        filter.type = 'bandpass';
        filter.connect(compressor);


        compressor.connect(context.destination)
        filter.connect(context.destination)

        mediaStreamSource = context.createMediaStreamSource( stream );
        mediaStreamSource.connect( filter );
    }
})();

如果您听到的是嘶嘶声而不是全谱噪声,则可以尝试使用一种高通滤波器。 我相信Web Audio API具有您可以实现的过滤器类型。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM