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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
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.5f; |
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 = 10; |
37 const float kDecayRate = 0.994f; // Power estimation decay rate. | 37 const float kDecayRate = 0.995f; // Power estimation decay rate. |
38 const float kMaxRelativeGainChange = 0.006f; | 38 const float kMaxRelativeGainChange = 0.005f; |
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 const float kMaxActiveSNR = 128.f; // 21dB | 41 const float kMaxActiveSNR = 128.f; // 21dB |
42 const float kMinInactiveSNR = 32.f; // 15dB | 42 const float kMinInactiveSNR = 32.f; // 15dB |
43 const size_t kGainUpdatePeriod = 10u; | 43 const size_t kGainUpdatePeriod = 10u; |
44 | 44 |
45 // Returns dot product of vectors |a| and |b| with size |length|. | 45 // Returns dot product of vectors |a| and |b| with size |length|. |
46 float DotProduct(const float* a, const float* b, size_t length) { | 46 float DotProduct(const float* a, const float* b, size_t length) { |
47 float ret = 0.f; | 47 float ret = 0.f; |
48 for (size_t i = 0; i < length; ++i) { | 48 for (size_t i = 0; i < length; ++i) { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 vad_.ProcessChunk(audio_s16_.data(), chunk_length_, sample_rate_hz_); | 344 vad_.ProcessChunk(audio_s16_.data(), chunk_length_, sample_rate_hz_); |
345 if (vad_.last_voice_probability() > kVoiceProbabilityThreshold) { | 345 if (vad_.last_voice_probability() > kVoiceProbabilityThreshold) { |
346 chunks_since_voice_ = 0; | 346 chunks_since_voice_ = 0; |
347 } else if (chunks_since_voice_ < kSpeechOffsetDelay) { | 347 } else if (chunks_since_voice_ < kSpeechOffsetDelay) { |
348 ++chunks_since_voice_; | 348 ++chunks_since_voice_; |
349 } | 349 } |
350 return chunks_since_voice_ < kSpeechOffsetDelay; | 350 return chunks_since_voice_ < kSpeechOffsetDelay; |
351 } | 351 } |
352 | 352 |
353 } // namespace webrtc | 353 } // namespace webrtc |
OLD | NEW |