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

Unified 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: Make gain change limit relative 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
index 436d174775922c95a059b9dc13b7fe9ae6d8a01b..35a38145891fd2a1040129908578cef786bc6d4a 100644
--- a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
+++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
@@ -8,10 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-//
-// Unit tests for intelligibility enhancer.
-//
-
#include <math.h>
#include <stdlib.h>
#include <algorithm>
@@ -29,73 +25,198 @@ namespace {
// Target output for ERB create test. Generated with matlab.
const float kTestCenterFreqs[] = {
- 13.169f, 26.965f, 41.423f, 56.577f, 72.461f, 89.113f, 106.57f, 124.88f,
- 144.08f, 164.21f, 185.34f, 207.5f, 230.75f, 255.16f, 280.77f, 307.66f,
- 335.9f, 365.56f, 396.71f, 429.44f, 463.84f, 500.f};
-const float kTestFilterBank[][2] = {{0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.f},
- {0.055556f, 0.2f},
- {0, 0.2f},
- {0, 0.2f},
- {0, 0.2f},
- {0, 0.2f}};
+ 14.5213f, 29.735f, 45.6781f, 62.3884f, 79.9058f, 98.2691f, 117.521f,
+ 137.708f, 158.879f, 181.084f, 204.378f, 228.816f, 254.459f, 281.371f,
+ 309.618f, 339.273f, 370.411f, 403.115f, 437.469f, 473.564f, 511.497f,
+ 551.371f, 593.293f, 637.386f, 683.77f, 732.581f, 783.96f, 838.06f,
+ 895.046f, 955.09f, 1018.38f, 1085.13f, 1155.54f, 1229.85f, 1308.32f,
+ 1391.22f, 1478.83f, 1571.5f, 1669.55f, 1773.37f, 1883.37f, 2000.f};
+const float kTestFilterBank[][33] = {
+ {0.2f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f},
+ {0.2f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f},
+ {0.2f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f},
+ {0.2f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f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0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.15873f, 0.333333f, 0.344828f, 0.357143f,
+ 0.25f, 0.196721f, 0.137931f, 0.0816327f, 0.f},
+ {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.172414f, 0.357143f,
+ 0.3125f, 0.245902f, 0.172414f, 0.102041f, 0.f},
+ {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.3125f, 0.327869f, 0.344828f, 0.204082f, 0.f},
+ {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.163934f, 0.344828f, 0.408163f, 0.5f},
+ {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.204082f, 0.5f}};
static_assert(arraysize(kTestCenterFreqs) == arraysize(kTestFilterBank),
"Test filterbank badly initialized.");
// Target output for gain solving test. Generated with matlab.
const size_t kTestStartFreq = 12; // Lowest integral frequency for ERBs.
-const float kTestZeroVar[] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f,
- 1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f,
- 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
+const float kTestZeroVar[] = {
+ 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0};
static_assert(arraysize(kTestCenterFreqs) == arraysize(kTestZeroVar),
- "Variance test data badly initialized.");
+ "Power test data badly initialized.");
const float kTestNonZeroVarLambdaTop[] = {
- 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f,
- 1.f, 1.f, 1.f, 0.f, 0.f, 0.0351f, 0.0636f, 0.0863f,
- 0.1037f, 0.1162f, 0.1236f, 0.1251f, 0.1189f, 0.0993f};
+ 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0};
static_assert(arraysize(kTestCenterFreqs) ==
arraysize(kTestNonZeroVarLambdaTop),
- "Variance test data badly initialized.");
+ "Power test data badly initialized.");
const float kMaxTestError = 0.005f;
// Enhancer initialization parameters.
-const int kSamples = 2000;
-const int kSampleRate = 1000;
+const int kSamples = 1000;
+const int kSampleRate = 4000;
const int kNumChannels = 1;
const int kFragmentSize = kSampleRate / 100;
} // namespace
-using std::vector;
-using intelligibility::VarianceArray;
-
class IntelligibilityEnhancerTest : public ::testing::Test {
protected:
IntelligibilityEnhancerTest()
: clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) {
- config_.sample_rate_hz = kSampleRate;
- enh_.reset(new IntelligibilityEnhancer(config_));
+ enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels));
}
- bool CheckUpdate(VarianceArray::StepType step_type) {
- config_.sample_rate_hz = kSampleRate;
- config_.var_type = step_type;
- enh_.reset(new IntelligibilityEnhancer(config_));
+ bool CheckUpdate() {
+ enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels));
float* clear_cursor = &clear_data_[0];
float* noise_cursor = &noise_data_[0];
for (int i = 0; i < kSamples; i += kFragmentSize) {
@@ -111,39 +232,26 @@ class IntelligibilityEnhancerTest : public ::testing::Test {
return false;
}
- IntelligibilityEnhancer::Config config_;
rtc::scoped_ptr<IntelligibilityEnhancer> enh_;
- vector<float> clear_data_;
- vector<float> noise_data_;
- vector<float> orig_data_;
+ std::vector<float> clear_data_;
+ std::vector<float> noise_data_;
+ std::vector<float> orig_data_;
};
-// For each class of generated data, tests that render stream is
-// updated when it should be for each variance update method.
+// For each class of generated data, tests that render stream is updated when
+// it should be.
TEST_F(IntelligibilityEnhancerTest, TestRenderUpdate) {
- vector<VarianceArray::StepType> step_types;
- step_types.push_back(VarianceArray::kStepInfinite);
- step_types.push_back(VarianceArray::kStepDecaying);
- step_types.push_back(VarianceArray::kStepWindowed);
- step_types.push_back(VarianceArray::kStepBlocked);
- step_types.push_back(VarianceArray::kStepBlockBasedMovingAverage);
- std::fill(noise_data_.begin(), noise_data_.end(), 0.0f);
- std::fill(orig_data_.begin(), orig_data_.end(), 0.0f);
- for (auto step_type : step_types) {
- std::fill(clear_data_.begin(), clear_data_.end(), 0.0f);
- EXPECT_FALSE(CheckUpdate(step_type));
- }
+ std::fill(noise_data_.begin(), noise_data_.end(), 0.f);
+ std::fill(orig_data_.begin(), orig_data_.end(), 0.f);
+ std::fill(clear_data_.begin(), clear_data_.end(), 0.f);
+ EXPECT_FALSE(CheckUpdate());
std::srand(1);
auto float_rand = []() { return std::rand() * 2.f / RAND_MAX - 1; };
std::generate(noise_data_.begin(), noise_data_.end(), float_rand);
- for (auto step_type : step_types) {
- EXPECT_FALSE(CheckUpdate(step_type));
- }
- for (auto step_type : step_types) {
- std::generate(clear_data_.begin(), clear_data_.end(), float_rand);
- orig_data_ = clear_data_;
- EXPECT_TRUE(CheckUpdate(step_type));
- }
+ EXPECT_FALSE(CheckUpdate());
+ std::generate(clear_data_.begin(), clear_data_.end(), float_rand);
+ orig_data_ = clear_data_;
+ EXPECT_TRUE(CheckUpdate());
}
// Tests ERB bank creation, comparing against matlab output.
@@ -163,26 +271,25 @@ TEST_F(IntelligibilityEnhancerTest, TestErbCreation) {
// against matlab output.
TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) {
ASSERT_EQ(kTestStartFreq, enh_->start_freq_);
- vector<float> sols(enh_->bank_size_);
+ std::vector<float> sols(enh_->bank_size_);
float lambda = -0.001f;
for (size_t i = 0; i < enh_->bank_size_; i++) {
- enh_->filtered_clear_var_[i] = 0.0f;
- enh_->filtered_noise_var_[i] = 0.0f;
- enh_->rho_[i] = 0.02f;
+ enh_->filtered_clear_pow_[i] = 0.f;
+ enh_->filtered_noise_pow_[i] = 0.f;
}
enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]);
for (size_t i = 0; i < enh_->bank_size_; i++) {
EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError);
}
for (size_t i = 0; i < enh_->bank_size_; i++) {
- enh_->filtered_clear_var_[i] = static_cast<float>(i + 1);
- enh_->filtered_noise_var_[i] = static_cast<float>(enh_->bank_size_ - i);
+ enh_->filtered_clear_pow_[i] = static_cast<float>(i + 1);
+ enh_->filtered_noise_pow_[i] = static_cast<float>(enh_->bank_size_ - i);
}
enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]);
for (size_t i = 0; i < enh_->bank_size_; i++) {
EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
}
- lambda = -1.0;
+ lambda = -1.f;
enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]);
for (size_t i = 0; i < enh_->bank_size_; i++) {
EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError);

Powered by Google App Engine
This is Rietveld 408576698