OLD | NEW |
1 // Copyright (c) 2010 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 |
11 #include <math.h> | 11 #include <math.h> |
(...skipping 22 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 float GetDecibel(float value) { | 36 float GetDecibel(float value) { |
37 if (value > 1.0e-100) | 37 if (value > 1.0e-100) |
38 return 20 * log10(value); | 38 return 20 * log10(value); |
39 return -2000.0; | 39 return -2000.0; |
40 } | 40 } |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 namespace speech_input { | 44 namespace speech { |
45 | 45 |
46 // Stores threshold-crossing histories for making decisions about the speech | 46 // Stores threshold-crossing histories for making decisions about the speech |
47 // state. | 47 // state. |
48 class EnergyEndpointer::HistoryRing { | 48 class EnergyEndpointer::HistoryRing { |
49 public: | 49 public: |
50 HistoryRing() : insertion_index_(0) {} | 50 HistoryRing() : insertion_index_(0) {} |
51 | 51 |
52 // Resets the ring to |size| elements each with state |initial_state| | 52 // Resets the ring to |size| elements each with state |initial_state| |
53 void SetRing(int size, bool initial_state); | 53 void SetRing(int size, bool initial_state); |
54 | 54 |
(...skipping 312 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 speech | 376 } // namespace speech |
OLD | NEW |