• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2019 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_NS_SPEECH_PROBABILITY_ESTIMATOR_H_
12 #define MODULES_AUDIO_PROCESSING_NS_SPEECH_PROBABILITY_ESTIMATOR_H_
13 
14 #include <array>
15 
16 #include "api/array_view.h"
17 #include "modules/audio_processing/ns/ns_common.h"
18 #include "modules/audio_processing/ns/signal_model_estimator.h"
19 
20 namespace webrtc {
21 
22 // Class for estimating the probability of speech.
23 class SpeechProbabilityEstimator {
24  public:
25   SpeechProbabilityEstimator();
26   SpeechProbabilityEstimator(const SpeechProbabilityEstimator&) = delete;
27   SpeechProbabilityEstimator& operator=(const SpeechProbabilityEstimator&) =
28       delete;
29 
30   // Compute speech probability.
31   void Update(
32       int32_t num_analyzed_frames,
33       rtc::ArrayView<const float, kFftSizeBy2Plus1> prior_snr,
34       rtc::ArrayView<const float, kFftSizeBy2Plus1> post_snr,
35       rtc::ArrayView<const float, kFftSizeBy2Plus1> conservative_noise_spectrum,
36       rtc::ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum,
37       float signal_spectral_sum,
38       float signal_energy);
39 
get_prior_probability()40   float get_prior_probability() const { return prior_speech_prob_; }
get_probability()41   rtc::ArrayView<const float> get_probability() { return speech_probability_; }
42 
43  private:
44   SignalModelEstimator signal_model_estimator_;
45   float prior_speech_prob_ = .5f;
46   std::array<float, kFftSizeBy2Plus1> speech_probability_;
47 };
48 
49 }  // namespace webrtc
50 
51 #endif  // MODULES_AUDIO_PROCESSING_NS_SPEECH_PROBABILITY_ESTIMATOR_H_
52