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 |
11 #include "webrtc/modules/audio_processing/vad/voice_activity_detector.h" | 11 #include "webrtc/modules/audio_processing/vad/voice_activity_detector.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "webrtc/test/testsupport/fileutils.h" | 17 #include "webrtc/test/testsupport/fileutils.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 namespace { | 20 namespace { |
21 | 21 |
22 const int kStartTimeSec = 16; | 22 const int kStartTimeSec = 16; |
23 const float kMeanSpeechProbability = 0.3f; | 23 const float kMeanSpeechProbability = 0.3f; |
24 const float kMaxNoiseProbability = 0.07f; | 24 const float kMaxNoiseProbability = 0.1f; |
25 const size_t kNumChunks = 300u; | 25 const size_t kNumChunks = 300u; |
26 const size_t kNumChunksPerIsacBlock = 3; | 26 const size_t kNumChunksPerIsacBlock = 3; |
27 | 27 |
28 void GenerateNoise(std::vector<int16_t>* data) { | 28 void GenerateNoise(std::vector<int16_t>* data) { |
29 for (size_t i = 0; i < data->size(); ++i) { | 29 for (size_t i = 0; i < data->size(); ++i) { |
30 // std::rand returns between 0 and RAND_MAX, but this will work because it | 30 // std::rand returns between 0 and RAND_MAX, but this will work because it |
31 // wraps into some random place. | 31 // wraps into some random place. |
32 (*data)[i] = std::rand(); | 32 (*data)[i] = std::rand(); |
33 } | 33 } |
34 } | 34 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // the default value, 1.f, which would ruin the |max_probability| value. | 159 // the default value, 1.f, which would ruin the |max_probability| value. |
160 if (i > kNumChunksPerIsacBlock) { | 160 if (i > kNumChunksPerIsacBlock) { |
161 max_probability = std::max(max_probability, vad.last_voice_probability()); | 161 max_probability = std::max(max_probability, vad.last_voice_probability()); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 EXPECT_LT(max_probability, kMaxNoiseProbability); | 165 EXPECT_LT(max_probability, kMaxNoiseProbability); |
166 } | 166 } |
167 | 167 |
168 } // namespace webrtc | 168 } // namespace webrtc |
OLD | NEW |