1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
Description: Ignore absent RNNoise
Author: Nicholas Guriev <guriev-ns@ya.ru>
Last-Update: Wed, 06 Nov 2024 19:31:23 +0300
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2617,6 +2617,15 @@ if (WIN32)
)
endif()
+if (NOT TG_OWT_USE_RNNOISE)
+ remove_target_sources(tg_owt ${webrtc_loc}
+ modules/audio_processing/agc2/rnn_vad/rnn_fc.cc
+ modules/audio_processing/agc2/rnn_vad/rnn_fc.h
+ modules/audio_processing/agc2/rnn_vad/rnn_gru.cc
+ modules/audio_processing/agc2/rnn_vad/rnn_gru.h
+ )
+endif()
+
set(export_targets tg_owt)
if (is_x86 OR is_x64)
list(APPEND export_targets
--- a/cmake/librnnoise.cmake
+++ b/cmake/librnnoise.cmake
@@ -1,3 +1,14 @@
+if (NOT TG_OWT_USE_RNNOISE)
+ add_library(librnnoise INTERFACE)
+ add_library(tg_owt::librnnoise ALIAS librnnoise)
+
+ target_compile_definitions(librnnoise
+ INTERFACE
+ WEBRTC_USE_RNNOISE=0
+ )
+ return()
+endif()
+
add_library(librnnoise OBJECT EXCLUDE_FROM_ALL)
init_target(librnnoise)
add_library(tg_owt::librnnoise ALIAS librnnoise)
--- a/src/modules/audio_processing/agc2/rnn_vad/rnn.cc
+++ b/src/modules/audio_processing/agc2/rnn_vad/rnn.cc
@@ -11,10 +11,15 @@
#include "modules/audio_processing/agc2/rnn_vad/rnn.h"
#include "rtc_base/checks.h"
+#include "rtc_base/logging.h"
+#if WEBRTC_USE_RNNOISE
#include "third_party/rnnoise/src/rnn_vad_weights.h"
+#endif
namespace webrtc {
namespace rnn_vad {
+
+#if WEBRTC_USE_RNNOISE
namespace {
using ::rnnoise::kInputLayerInputSize;
@@ -87,5 +92,23 @@ float RnnVad::ComputeVadProbability(
return output_.data()[0];
}
+#else // WEBRTC_USE_RNNOISE
+
+RnnVad::RnnVad(const AvailableCpuFeatures& cpu_features) {
+ RTC_LOG(LS_INFO) << "Noise cancellation feature is unavailable";
+};
+
+RnnVad::~RnnVad() {}
+
+void RnnVad::Reset() {}
+
+float RnnVad::ComputeVadProbability(
+ rtc::ArrayView<const float, kFeatureVectorSize> feature_vector,
+ bool is_silence) {
+ return is_silence ? 0.f : 1.f;
+}
+
+#endif // WEBRTC_USE_RNNOISE
+
} // namespace rnn_vad
} // namespace webrtc
--- a/src/modules/audio_processing/agc2/rnn_vad/rnn.h
+++ b/src/modules/audio_processing/agc2/rnn_vad/rnn.h
@@ -23,6 +23,10 @@
#include "modules/audio_processing/agc2/rnn_vad/rnn_fc.h"
#include "modules/audio_processing/agc2/rnn_vad/rnn_gru.h"
+#ifndef WEBRTC_USE_RNNOISE
+#define WEBRTC_USE_RNNOISE 1
+#endif
+
namespace webrtc {
namespace rnn_vad {
@@ -42,9 +46,11 @@ class RnnVad {
bool is_silence);
private:
+#if WEBRTC_USE_RNNOISE
FullyConnectedLayer input_;
GatedRecurrentLayer hidden_;
FullyConnectedLayer output_;
+#endif
};
} // namespace rnn_vad
|