OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 16 matching lines...) Expand all Loading... |
27 const size_t kErbResolution = 2; | 27 const size_t kErbResolution = 2; |
28 const int kWindowSizeMs = 16; | 28 const int kWindowSizeMs = 16; |
29 const int kChunkSizeMs = 10; // Size provided by APM. | 29 const int kChunkSizeMs = 10; // Size provided by APM. |
30 const float kClipFreqKhz = 0.2f; | 30 const float kClipFreqKhz = 0.2f; |
31 const float kKbdAlpha = 1.5f; | 31 const float kKbdAlpha = 1.5f; |
32 const float kLambdaBot = -1.f; // Extreme values in bisection | 32 const float kLambdaBot = -1.f; // Extreme values in bisection |
33 const float kLambdaTop = -1e-5f; // search for lamda. | 33 const float kLambdaTop = -1e-5f; // search for lamda. |
34 const float kVoiceProbabilityThreshold = 0.02f; | 34 const float kVoiceProbabilityThreshold = 0.02f; |
35 // Number of chunks after voice activity which is still considered speech. | 35 // Number of chunks after voice activity which is still considered speech. |
36 const size_t kSpeechOffsetDelay = 80; | 36 const size_t kSpeechOffsetDelay = 80; |
37 const float kDecayRate = 0.98f; // Power estimation decay rate. | 37 const float kDecayRate = 0.994f; // Power estimation decay rate. |
38 const float kMaxRelativeGainChange = 0.04f; // Maximum relative change in gain. | 38 const float kMaxRelativeGainChange = 0.006f; |
39 const float kRho = 0.0004f; // Default production and interpretation SNR. | 39 const float kRho = 0.0004f; // Default production and interpretation SNR. |
40 const float kPowerNormalizationFactor = 1.f / (1 << 30); | 40 const float kPowerNormalizationFactor = 1.f / (1 << 30); |
41 | 41 |
42 // Returns dot product of vectors |a| and |b| with size |length|. | 42 // Returns dot product of vectors |a| and |b| with size |length|. |
43 float DotProduct(const float* a, const float* b, size_t length) { | 43 float DotProduct(const float* a, const float* b, size_t length) { |
44 float ret = 0.f; | 44 float ret = 0.f; |
45 for (size_t i = 0; i < length; ++i) { | 45 for (size_t i = 0; i < length; ++i) { |
46 ret += a[i] * b[i]; | 46 ret += a[i] * b[i]; |
47 } | 47 } |
48 return ret; | 48 return ret; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 vad_.ProcessChunk(audio_s16_.data(), chunk_length_, sample_rate_hz_); | 308 vad_.ProcessChunk(audio_s16_.data(), chunk_length_, sample_rate_hz_); |
309 if (vad_.last_voice_probability() > kVoiceProbabilityThreshold) { | 309 if (vad_.last_voice_probability() > kVoiceProbabilityThreshold) { |
310 chunks_since_voice_ = 0; | 310 chunks_since_voice_ = 0; |
311 } else if (chunks_since_voice_ < kSpeechOffsetDelay) { | 311 } else if (chunks_since_voice_ < kSpeechOffsetDelay) { |
312 ++chunks_since_voice_; | 312 ++chunks_since_voice_; |
313 } | 313 } |
314 return chunks_since_voice_ < kSpeechOffsetDelay; | 314 return chunks_since_voice_ < kSpeechOffsetDelay; |
315 } | 315 } |
316 | 316 |
317 } // namespace webrtc | 317 } // namespace webrtc |
OLD | NEW |