LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/audio_processing/vad - voice_activity_detector.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 5 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2015 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 WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_
      12             : #define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_
      13             : 
      14             : #include <memory>
      15             : #include <vector>
      16             : 
      17             : #include "webrtc/common_audio/resampler/include/resampler.h"
      18             : #include "webrtc/modules/audio_processing/vad/vad_audio_proc.h"
      19             : #include "webrtc/modules/audio_processing/vad/common.h"
      20             : #include "webrtc/modules/audio_processing/vad/pitch_based_vad.h"
      21             : #include "webrtc/modules/audio_processing/vad/standalone_vad.h"
      22             : 
      23             : namespace webrtc {
      24             : 
      25             : // A Voice Activity Detector (VAD) that combines the voice probability from the
      26             : // StandaloneVad and PitchBasedVad to get a more robust estimation.
      27           0 : class VoiceActivityDetector {
      28             :  public:
      29             :   VoiceActivityDetector();
      30             :   ~VoiceActivityDetector();
      31             : 
      32             :   // Processes each audio chunk and estimates the voice probability. The maximum
      33             :   // supported sample rate is 32kHz.
      34             :   // TODO(aluebs): Change |length| to size_t.
      35             :   void ProcessChunk(const int16_t* audio, size_t length, int sample_rate_hz);
      36             : 
      37             :   // Returns a vector of voice probabilities for each chunk. It can be empty for
      38             :   // some chunks, but it catches up afterwards returning multiple values at
      39             :   // once.
      40           0 :   const std::vector<double>& chunkwise_voice_probabilities() const {
      41           0 :     return chunkwise_voice_probabilities_;
      42             :   }
      43             : 
      44             :   // Returns a vector of RMS values for each chunk. It has the same length as
      45             :   // chunkwise_voice_probabilities().
      46           0 :   const std::vector<double>& chunkwise_rms() const { return chunkwise_rms_; }
      47             : 
      48             :   // Returns the last voice probability, regardless of the internal
      49             :   // implementation, although it has a few chunks of delay.
      50           0 :   float last_voice_probability() const { return last_voice_probability_; }
      51             : 
      52             :  private:
      53             :   // TODO(aluebs): Change these to float.
      54             :   std::vector<double> chunkwise_voice_probabilities_;
      55             :   std::vector<double> chunkwise_rms_;
      56             : 
      57             :   float last_voice_probability_;
      58             : 
      59             :   Resampler resampler_;
      60             :   VadAudioProc audio_processing_;
      61             : 
      62             :   std::unique_ptr<StandaloneVad> standalone_vad_;
      63             :   PitchBasedVad pitch_based_vad_;
      64             : 
      65             :   int16_t resampled_[kLength10Ms];
      66             :   AudioFeatures features_;
      67             : };
      68             : 
      69             : }  // namespace webrtc
      70             : 
      71             : #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_

Generated by: LCOV version 1.13