OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 void EnergyEndpointer::ProcessAudioFrame(int64 time_us, | 232 void EnergyEndpointer::ProcessAudioFrame(int64 time_us, |
233 const int16* samples, | 233 const int16* samples, |
234 int num_samples, | 234 int num_samples, |
235 float* rms_out) { | 235 float* rms_out) { |
236 endpointer_time_us_ = time_us; | 236 endpointer_time_us_ = time_us; |
237 float rms = RMS(samples, num_samples); | 237 float rms = RMS(samples, num_samples); |
238 | 238 |
239 // Check that this is user input audio vs. pre-input adaptation audio. | 239 // Check that this is user input audio vs. pre-input adaptation audio. |
240 // Input audio starts when the user indicates start of input, by e.g. | 240 // Input audio starts when the user indicates start of input, by e.g. |
241 // pressing push-to-talk. Audio recieved prior to that is used to update | 241 // pressing push-to-talk. Audio received prior to that is used to update |
242 // noise and speech level estimates. | 242 // noise and speech level estimates. |
243 if (!estimating_environment_) { | 243 if (!estimating_environment_) { |
244 bool decision = false; | 244 bool decision = false; |
245 if ((endpointer_time_us_ - user_input_start_time_us_) < | 245 if ((endpointer_time_us_ - user_input_start_time_us_) < |
246 Secs2Usecs(params_.contamination_rejection_period())) { | 246 Secs2Usecs(params_.contamination_rejection_period())) { |
247 decision = false; | 247 decision = false; |
248 DVLOG(1) << "decision: forced to false, time: " << endpointer_time_us_; | 248 DVLOG(1) << "decision: forced to false, time: " << endpointer_time_us_; |
249 } else { | 249 } else { |
250 decision = (rms > decision_threshold_); | 250 decision = (rms > decision_threshold_); |
251 } | 251 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 decision_threshold_ = params_.min_decision_threshold(); | 367 decision_threshold_ = params_.min_decision_threshold(); |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 EpStatus EnergyEndpointer::Status(int64* status_time) const { | 371 EpStatus EnergyEndpointer::Status(int64* status_time) const { |
372 *status_time = history_->EndTime(); | 372 *status_time = history_->EndTime(); |
373 return status_; | 373 return status_; |
374 } | 374 } |
375 | 375 |
376 } // namespace content | 376 } // namespace content |
OLD | NEW |