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

Side by Side Diff: content/browser/speech/endpointer/energy_endpointer.cc

Issue 6597071: Add a noise indicator to the speech bubble volume indicator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // To know more about the algorithm used and the original code which this is 5 // To know more about the algorithm used and the original code which this is
6 // based of, see 6 // based of, see
7 // https://wiki.corp.google.com/twiki/bin/view/Main/ChromeGoogleCodeXRef 7 // https://wiki.corp.google.com/twiki/bin/view/Main/ChromeGoogleCodeXRef
8 8
9 #include "content/browser/speech/endpointer/energy_endpointer.h" 9 #include "content/browser/speech/endpointer/energy_endpointer.h"
10 10
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // Set a floor 320 // Set a floor
321 if (decision_threshold_ < params_.min_decision_threshold()) 321 if (decision_threshold_ < params_.min_decision_threshold())
322 decision_threshold_ = params_.min_decision_threshold(); 322 decision_threshold_ = params_.min_decision_threshold();
323 } 323 }
324 324
325 // Update speech and noise levels. 325 // Update speech and noise levels.
326 UpdateLevels(rms); 326 UpdateLevels(rms);
327 ++frame_counter_; 327 ++frame_counter_;
328 328
329 if (rms_out) { 329 if (rms_out) {
330 *rms_out = -120.0; 330 *rms_out = -2000.0;
331 if ((noise_level_ > 0.0) && ((rms / noise_level_ ) > 0.000001)) 331 if (rms > 1.0e-100)
bulach 2011/03/01 17:39:04 again, it may be nicer to define these magic const
332 *rms_out = static_cast<float>(20.0 * log10(rms / noise_level_)); 332 *rms_out = 20 * log10(rms);
333 } 333 }
334 } 334 }
335 335
336 float EnergyEndpointer::GetNoiseLevelDB() const {
337 float levelDB = -2000.0;
338 if (noise_level_ > 1.0e-100)
339 levelDB = 20 * log10(noise_level_);
340 return levelDB;
bulach 2011/03/01 17:39:04 ditto, dB and named constants..
341 }
342
336 void EnergyEndpointer::UpdateLevels(float rms) { 343 void EnergyEndpointer::UpdateLevels(float rms) {
337 // Update quickly initially. We assume this is noise and that 344 // Update quickly initially. We assume this is noise and that
338 // speech is 6dB above the noise. 345 // speech is 6dB above the noise.
339 if (frame_counter_ < fast_update_frames_) { 346 if (frame_counter_ < fast_update_frames_) {
340 // Alpha increases from 0 to (k-1)/k where k is the number of time 347 // Alpha increases from 0 to (k-1)/k where k is the number of time
341 // steps in the initial adaptation period. 348 // steps in the initial adaptation period.
342 float alpha = static_cast<float>(frame_counter_) / 349 float alpha = static_cast<float>(frame_counter_) /
343 static_cast<float>(fast_update_frames_); 350 static_cast<float>(fast_update_frames_);
344 noise_level_ = (alpha * noise_level_) + ((1 - alpha) * rms); 351 noise_level_ = (alpha * noise_level_) + ((1 - alpha) * rms);
345 DVLOG(1) << "FAST UPDATE, frame_counter_ " << frame_counter_ 352 DVLOG(1) << "FAST UPDATE, frame_counter_ " << frame_counter_
(...skipping 14 matching lines...) Expand all
360 decision_threshold_ = params_.min_decision_threshold(); 367 decision_threshold_ = params_.min_decision_threshold();
361 } 368 }
362 } 369 }
363 370
364 EpStatus EnergyEndpointer::Status(int64* status_time) const { 371 EpStatus EnergyEndpointer::Status(int64* status_time) const {
365 *status_time = history_->EndTime(); 372 *status_time = history_->EndTime();
366 return status_; 373 return status_;
367 } 374 }
368 375
369 } // namespace speech 376 } // namespace speech
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698