1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_AUDIO_PROCESSING_AGC2_VAD_WITH_LEVEL_H_ 12 #define MODULES_AUDIO_PROCESSING_AGC2_VAD_WITH_LEVEL_H_ 13 14 #include "common_audio/resampler/include/push_resampler.h" 15 #include "modules/audio_processing/agc2/rnn_vad/features_extraction.h" 16 #include "modules/audio_processing/agc2/rnn_vad/rnn.h" 17 #include "modules/audio_processing/include/audio_frame_view.h" 18 19 namespace webrtc { 20 class VadWithLevel { 21 public: 22 struct LevelAndProbability { LevelAndProbabilityLevelAndProbability23 constexpr LevelAndProbability(float prob, float rms, float peak) 24 : speech_probability(prob), 25 speech_rms_dbfs(rms), 26 speech_peak_dbfs(peak) {} 27 LevelAndProbability() = default; 28 float speech_probability = 0; 29 float speech_rms_dbfs = 0; // Root mean square in decibels to full-scale. 30 float speech_peak_dbfs = 0; 31 }; 32 33 VadWithLevel(); 34 ~VadWithLevel(); 35 36 LevelAndProbability AnalyzeFrame(AudioFrameView<const float> frame); 37 38 private: 39 void SetSampleRate(int sample_rate_hz); 40 41 rnn_vad::RnnBasedVad rnn_vad_; 42 rnn_vad::FeaturesExtractor features_extractor_; 43 PushResampler<float> resampler_; 44 }; 45 46 } // namespace webrtc 47 48 #endif // MODULES_AUDIO_PROCESSING_AGC2_VAD_WITH_LEVEL_H_ 49