Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc

Issue 1693823004: Use VAD to get a better speech power estimation in the IntelligibilityEnhancer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@pow
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 const int kSampleRate = 1000; 74 const int kSampleRate = 1000;
75 const int kNumChannels = 1; 75 const int kNumChannels = 1;
76 const int kFragmentSize = kSampleRate / 100; 76 const int kFragmentSize = kSampleRate / 100;
77 77
78 } // namespace 78 } // namespace
79 79
80 class IntelligibilityEnhancerTest : public ::testing::Test { 80 class IntelligibilityEnhancerTest : public ::testing::Test {
81 protected: 81 protected:
82 IntelligibilityEnhancerTest() 82 IntelligibilityEnhancerTest()
83 : clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) { 83 : clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) {
84 config_.sample_rate_hz = kSampleRate; 84 enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels));
85 enh_.reset(new IntelligibilityEnhancer(config_));
86 } 85 }
87 86
88 bool CheckUpdate() { 87 bool CheckUpdate() {
89 config_.sample_rate_hz = kSampleRate; 88 enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels));
90 enh_.reset(new IntelligibilityEnhancer(config_));
91 float* clear_cursor = &clear_data_[0]; 89 float* clear_cursor = &clear_data_[0];
92 float* noise_cursor = &noise_data_[0]; 90 float* noise_cursor = &noise_data_[0];
93 for (int i = 0; i < kSamples; i += kFragmentSize) { 91 for (int i = 0; i < kSamples; i += kFragmentSize) {
94 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels); 92 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
95 clear_cursor += kFragmentSize; 93 clear_cursor += kFragmentSize;
96 noise_cursor += kFragmentSize; 94 noise_cursor += kFragmentSize;
97 } 95 }
98 for (int i = 0; i < kSamples; i++) { 96 for (int i = 0; i < kSamples; i++) {
99 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) { 97 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) {
100 return true; 98 return true;
101 } 99 }
102 } 100 }
103 return false; 101 return false;
104 } 102 }
105 103
106 IntelligibilityEnhancer::Config config_;
107 rtc::scoped_ptr<IntelligibilityEnhancer> enh_; 104 rtc::scoped_ptr<IntelligibilityEnhancer> enh_;
108 std::vector<float> clear_data_; 105 std::vector<float> clear_data_;
109 std::vector<float> noise_data_; 106 std::vector<float> noise_data_;
110 std::vector<float> orig_data_; 107 std::vector<float> orig_data_;
111 }; 108 };
112 109
113 // For each class of generated data, tests that render stream is updated when 110 // For each class of generated data, tests that render stream is updated when
114 // it should be. 111 // it should be.
115 TEST_F(IntelligibilityEnhancerTest, TestRenderUpdate) { 112 TEST_F(IntelligibilityEnhancerTest, TestRenderUpdate) {
116 std::fill(noise_data_.begin(), noise_data_.end(), 0.0f); 113 std::fill(noise_data_.begin(), noise_data_.end(), 0.0f);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); 160 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
164 } 161 }
165 lambda = -1.0; 162 lambda = -1.0;
166 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); 163 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]);
167 for (size_t i = 0; i < enh_->bank_size_; i++) { 164 for (size_t i = 0; i < enh_->bank_size_; i++) {
168 EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError); 165 EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError);
169 } 166 }
170 } 167 }
171 168
172 } // namespace webrtc 169 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698