OLD | NEW |
---|---|
(Empty) | |
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 <vector> | |
15 | |
16 #include "webrtc/base/scoped_ptr.h" | |
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 class VoiceActivityDetector { | |
28 public: | |
29 VoiceActivityDetector(); | |
30 | |
31 // Processes each audio chunk and estimates the voice probability. The maximum | |
32 // supported sample rate is 32kHz. | |
33 void ProcessChunk(const int16_t* audio, int length, int sample_rate_hz); | |
Andrew MacDonald
2015/06/16 22:18:32
Should length be a size_t?
aluebs-webrtc
2015/06/17 01:44:31
I tried this, but realized it required changes in
| |
34 | |
35 // Returns a vector of voice probabilities for each chunk. It can be empty for | |
36 // some chunks, but it catches up afterwards returning multiple values at | |
37 // once. | |
38 const std::vector<double>& chunkwise_voice_probabilities() const { | |
39 return chunkwise_voice_probabilities_; | |
40 } | |
41 // Returns a vector of RMS values for each chunk. It has the same length as | |
Andrew MacDonald
2015/06/16 22:18:32
Vertical space above this line.
aluebs-webrtc
2015/06/17 01:44:31
Done.
| |
42 // chunkwise_voice_probabilities(). | |
43 const std::vector<double>& chunkwise_rms() const { return chunkwise_rms_; } | |
44 | |
45 // Returns the last voice probability, regardless of the internal | |
46 // implementation, although it has a few chunks of delay. | |
47 float last_voice_probability() const { return last_voice_probability_; } | |
48 | |
49 private: | |
50 std::vector<double> chunkwise_voice_probabilities_; | |
51 std::vector<double> chunkwise_rms_; | |
52 | |
53 float last_voice_probability_; | |
54 | |
55 Resampler resampler_; | |
56 VadAudioProc audio_processing_; | |
57 | |
58 rtc::scoped_ptr<StandaloneVad> standalone_vad_; | |
59 PitchBasedVad pitch_based_vad_; | |
60 | |
61 int16_t resampled_[kLength10Ms]; | |
62 AudioFeatures features_; | |
63 }; | |
64 | |
65 } // namespace webrtc | |
66 | |
67 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_ | |
OLD | NEW |