| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 const double kNeutralProbability = 0.5; | 24 const double kNeutralProbability = 0.5; |
| 25 const double kLowProbability = 0.01; | 25 const double kLowProbability = 0.01; |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 VoiceActivityDetector::VoiceActivityDetector() | 29 VoiceActivityDetector::VoiceActivityDetector() |
| 30 : last_voice_probability_(kDefaultVoiceValue), | 30 : last_voice_probability_(kDefaultVoiceValue), |
| 31 standalone_vad_(StandaloneVad::Create()) { | 31 standalone_vad_(StandaloneVad::Create()) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 VoiceActivityDetector::~VoiceActivityDetector() = default; |
| 35 |
| 34 // Because ISAC has a different chunk length, it updates | 36 // Because ISAC has a different chunk length, it updates |
| 35 // |chunkwise_voice_probabilities_| and |chunkwise_rms_| when there is new data. | 37 // |chunkwise_voice_probabilities_| and |chunkwise_rms_| when there is new data. |
| 36 // Otherwise it clears them. | 38 // Otherwise it clears them. |
| 37 void VoiceActivityDetector::ProcessChunk(const int16_t* audio, | 39 void VoiceActivityDetector::ProcessChunk(const int16_t* audio, |
| 38 size_t length, | 40 size_t length, |
| 39 int sample_rate_hz) { | 41 int sample_rate_hz) { |
| 40 RTC_DCHECK_EQ(static_cast<int>(length), sample_rate_hz / 100); | 42 RTC_DCHECK_EQ(static_cast<int>(length), sample_rate_hz / 100); |
| 41 RTC_DCHECK_LE(length, kMaxLength); | 43 RTC_DCHECK_LE(length, kMaxLength); |
| 42 // Resample to the required rate. | 44 // Resample to the required rate. |
| 43 const int16_t* resampled_ptr = audio; | 45 const int16_t* resampled_ptr = audio; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 0); | 78 0); |
| 77 RTC_CHECK_GE(pitch_based_vad_.VoicingProbability( | 79 RTC_CHECK_GE(pitch_based_vad_.VoicingProbability( |
| 78 features_, &chunkwise_voice_probabilities_[0]), | 80 features_, &chunkwise_voice_probabilities_[0]), |
| 79 0); | 81 0); |
| 80 } | 82 } |
| 81 last_voice_probability_ = chunkwise_voice_probabilities_.back(); | 83 last_voice_probability_ = chunkwise_voice_probabilities_.back(); |
| 82 } | 84 } |
| 83 } | 85 } |
| 84 | 86 |
| 85 } // namespace webrtc | 87 } // namespace webrtc |
| OLD | NEW |