mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-27 16:16:35 +03:00
fix denoise under gate vad, keep state always initd
This commit is contained in:
+12
-9
@@ -64,6 +64,10 @@ void capture_data_callback(ma_device *pDevice, void *pOutput, const void *pInput
|
|||||||
AudioManager::AudioManager() {
|
AudioManager::AudioManager() {
|
||||||
m_ok = true;
|
m_ok = true;
|
||||||
|
|
||||||
|
#ifdef WITH_RNNOISE
|
||||||
|
RNNoiseInitialize();
|
||||||
|
#endif
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
m_encoder = opus_encoder_create(48000, 2, OPUS_APPLICATION_VOIP, &err);
|
m_encoder = opus_encoder_create(48000, 2, OPUS_APPLICATION_VOIP, &err);
|
||||||
if (err != OPUS_OK) {
|
if (err != OPUS_OK) {
|
||||||
@@ -426,13 +430,20 @@ void AudioManager::OnCapturedPCM(const int16_t *pcm, ma_uint32 frames) {
|
|||||||
static std::array<float, 480> denoised_L;
|
static std::array<float, 480> denoised_L;
|
||||||
static std::array<float, 480> denoised_R;
|
static std::array<float, 480> denoised_R;
|
||||||
|
|
||||||
|
bool m_rnnoise_passed = false;
|
||||||
|
#ifdef WITH_RNNOISE
|
||||||
|
if (m_vad_method == VADMethod::RNNoise || m_enable_noise_suppression) {
|
||||||
|
m_rnnoise_passed = CheckVADRNNoise(new_pcm.data(), denoised_L.data(), denoised_R.data());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (m_vad_method) {
|
switch (m_vad_method) {
|
||||||
case VADMethod::Gate:
|
case VADMethod::Gate:
|
||||||
if (!CheckVADVoiceGate()) return;
|
if (!CheckVADVoiceGate()) return;
|
||||||
break;
|
break;
|
||||||
#ifdef WITH_RNNOISE
|
#ifdef WITH_RNNOISE
|
||||||
case VADMethod::RNNoise:
|
case VADMethod::RNNoise:
|
||||||
if (!CheckVADRNNoise(new_pcm.data(), denoised_L.data(), denoised_R.data())) return;
|
if (!m_rnnoise_passed) return;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -588,14 +599,6 @@ void AudioManager::SetVADMethod(const std::string &method) {
|
|||||||
void AudioManager::SetVADMethod(VADMethod method) {
|
void AudioManager::SetVADMethod(VADMethod method) {
|
||||||
spdlog::get("audio")->debug("Setting VAD method to enum {}", static_cast<int>(method));
|
spdlog::get("audio")->debug("Setting VAD method to enum {}", static_cast<int>(method));
|
||||||
m_vad_method = method;
|
m_vad_method = method;
|
||||||
|
|
||||||
#ifdef WITH_RNNOISE
|
|
||||||
if (method == VADMethod::RNNoise) {
|
|
||||||
RNNoiseInitialize();
|
|
||||||
} else {
|
|
||||||
RNNoiseUninitialize();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioManager::VADMethod AudioManager::GetVADMethod() const {
|
AudioManager::VADMethod AudioManager::GetVADMethod() const {
|
||||||
|
|||||||
Reference in New Issue
Block a user