werman / noise-suppression-for-voice

Noise suppression plugin based on Xiph's RNNoise
GNU General Public License v3.0
4.73k stars 228 forks source link

Using the Retroactive VAD breaks VAD Grace Period. #133

Closed cyrusduong closed 2 years ago

cyrusduong commented 2 years ago

When using Retroactive Grace Period I think the normal grace period breaks.

Saying the word "Click", for example. Setting Retroactive VAD slider to 5, appears to unmute the beginning of the word, but the ending is now clipped/muted.

Does this bool always compute as true (since outblock will always be greater than the last index we record)? RnNoiseCommonPlugin.cpp#L156

Should outblock->idx and lastBlockIdx be swapped or the result passed to fabs()? Or only allow the retroactive check to only unmute.

Alternatively... I'm not sure if we should check the blocks for over last VAD threshold. We already reduce that the muted state for any given block is UNMUTED_VAD or MUTED from the grace and denoise above.

Would it be sufficient to just UNMUTE_RETRO_VAD how many X blocks ahead of any instance of UNMUTED_VAD found?

if (retroactiveVADGraceBlocks > 0) {
    for (auto &channel: m_channels) {
        for (uint32_t blockIdx = 0; blockIdx < (blocksFromRnnoise - retroactiveVADGraceBlocks); blockIdx++) {
            auto &outBlock = channel.rnnoiseOutput.rbegin()[blockIdx];
            auto &lookAhead = channel.rnnoiseOutput.rbegin()[blockIdx + retroactiveVADGraceBlocks];

            if (outBlock->muteState == ChunkUnmuteState::MUTED && lookAhead->muteState == ChunkUnmuteState::UNMUTED_VAD) {
                outBlock->muteState == ChunkUnmuteState::UNMUTED_RETRO_VAD;
                    if (channel.idx == 0) {
                        stats.retroactiveVADGraceBlocks++;
                    }
                }
            }
        }
    }
}    

Sorry if this did not help, I am not familiar with C++ but I really like/and want to be able to use this plugin hopefully this is enough to figure out/reproduce the issue I am having?

werman commented 2 years ago

Ugh, could you try this commit https://github.com/werman/noise-suppression-for-voice/commit/b31564e1a5fc5906209a596dfb737486d3b482be ? Either compile yourself or wait until CI builds the artifacts.

cyrusduong commented 2 years ago

Checking.

cyrusduong commented 2 years ago

Latest build works - Thank you so much!

werman commented 2 years ago

Thanks for checking, I'll make a new release then...