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 #ifndef CONTENT_BROWSER_SPEECH_ENDPOINTER_ENDPOINTER_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_ENDPOINTER_ENDPOINTER_H_ |
6 #define CONTENT_BROWSER_SPEECH_ENDPOINTER_ENDPOINTER_H_ | 6 #define CONTENT_BROWSER_SPEECH_ENDPOINTER_ENDPOINTER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include <stdint.h> |
| 9 |
9 #include "content/browser/speech/endpointer/energy_endpointer.h" | 10 #include "content/browser/speech/endpointer/energy_endpointer.h" |
10 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
11 | 12 |
12 class EpStatus; | 13 class EpStatus; |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 class AudioChunk; | 17 class AudioChunk; |
17 | 18 |
18 // A simple interface to the underlying energy-endpointer implementation, this | 19 // A simple interface to the underlying energy-endpointer implementation, this |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 // Start user input. This should be called when the user indicates start of | 61 // Start user input. This should be called when the user indicates start of |
61 // input, e.g. by pressing a button. | 62 // input, e.g. by pressing a button. |
62 void SetUserInputMode(); | 63 void SetUserInputMode(); |
63 | 64 |
64 // Process a segment of audio, which may be more than one frame. | 65 // Process a segment of audio, which may be more than one frame. |
65 // The status of the last frame will be returned. | 66 // The status of the last frame will be returned. |
66 EpStatus ProcessAudio(const AudioChunk& raw_audio, float* rms_out); | 67 EpStatus ProcessAudio(const AudioChunk& raw_audio, float* rms_out); |
67 | 68 |
68 // Get the status of the endpointer. | 69 // Get the status of the endpointer. |
69 EpStatus Status(int64 *time_us); | 70 EpStatus Status(int64_t* time_us); |
70 | 71 |
71 // Returns true if the endpointer detected reasonable audio levels above | 72 // Returns true if the endpointer detected reasonable audio levels above |
72 // background noise which could be user speech, false if not. | 73 // background noise which could be user speech, false if not. |
73 bool DidStartReceivingSpeech() const { | 74 bool DidStartReceivingSpeech() const { |
74 return speech_previously_detected_; | 75 return speech_previously_detected_; |
75 } | 76 } |
76 | 77 |
77 bool IsEstimatingEnvironment() const { | 78 bool IsEstimatingEnvironment() const { |
78 return energy_endpointer_.estimating_environment(); | 79 return energy_endpointer_.estimating_environment(); |
79 } | 80 } |
80 | 81 |
81 void set_speech_input_complete_silence_length(int64 time_us) { | 82 void set_speech_input_complete_silence_length(int64_t time_us) { |
82 speech_input_complete_silence_length_us_ = time_us; | 83 speech_input_complete_silence_length_us_ = time_us; |
83 } | 84 } |
84 | 85 |
85 void set_long_speech_input_complete_silence_length(int64 time_us) { | 86 void set_long_speech_input_complete_silence_length(int64_t time_us) { |
86 long_speech_input_complete_silence_length_us_ = time_us; | 87 long_speech_input_complete_silence_length_us_ = time_us; |
87 } | 88 } |
88 | 89 |
89 void set_speech_input_possibly_complete_silence_length(int64 time_us) { | 90 void set_speech_input_possibly_complete_silence_length(int64_t time_us) { |
90 speech_input_possibly_complete_silence_length_us_ = time_us; | 91 speech_input_possibly_complete_silence_length_us_ = time_us; |
91 } | 92 } |
92 | 93 |
93 void set_long_speech_length(int64 time_us) { | 94 void set_long_speech_length(int64_t time_us) { |
94 long_speech_length_us_ = time_us; | 95 long_speech_length_us_ = time_us; |
95 } | 96 } |
96 | 97 |
97 bool speech_input_complete() const { | 98 bool speech_input_complete() const { |
98 return speech_input_complete_; | 99 return speech_input_complete_; |
99 } | 100 } |
100 | 101 |
101 // RMS background noise level in dB. | 102 // RMS background noise level in dB. |
102 float NoiseLevelDb() const { return energy_endpointer_.GetNoiseLevelDb(); } | 103 float NoiseLevelDb() const { return energy_endpointer_.GetNoiseLevelDb(); } |
103 | 104 |
104 private: | 105 private: |
105 // Reset internal states. Helper method common to initial input utterance | 106 // Reset internal states. Helper method common to initial input utterance |
106 // and following input utternaces. | 107 // and following input utternaces. |
107 void Reset(); | 108 void Reset(); |
108 | 109 |
109 // Minimum allowable length of speech input. | 110 // Minimum allowable length of speech input. |
110 int64 speech_input_minimum_length_us_; | 111 int64_t speech_input_minimum_length_us_; |
111 | 112 |
112 // The speechInputPossiblyComplete event signals that silence/noise has been | 113 // The speechInputPossiblyComplete event signals that silence/noise has been |
113 // detected for a *short* amount of time after some speech has been detected. | 114 // detected for a *short* amount of time after some speech has been detected. |
114 // This proporty specifies the time period. | 115 // This proporty specifies the time period. |
115 int64 speech_input_possibly_complete_silence_length_us_; | 116 int64_t speech_input_possibly_complete_silence_length_us_; |
116 | 117 |
117 // The speechInputComplete event signals that silence/noise has been | 118 // The speechInputComplete event signals that silence/noise has been |
118 // detected for a *long* amount of time after some speech has been detected. | 119 // detected for a *long* amount of time after some speech has been detected. |
119 // This property specifies the time period. | 120 // This property specifies the time period. |
120 int64 speech_input_complete_silence_length_us_; | 121 int64_t speech_input_complete_silence_length_us_; |
121 | 122 |
122 // Same as above, this specifies the required silence period after speech | 123 // Same as above, this specifies the required silence period after speech |
123 // detection. This period is used instead of | 124 // detection. This period is used instead of |
124 // speech_input_complete_silence_length_ when the utterance is longer than | 125 // speech_input_complete_silence_length_ when the utterance is longer than |
125 // long_speech_length_. This parameter is optional. | 126 // long_speech_length_. This parameter is optional. |
126 int64 long_speech_input_complete_silence_length_us_; | 127 int64_t long_speech_input_complete_silence_length_us_; |
127 | 128 |
128 // The period of time after which the endpointer should consider | 129 // The period of time after which the endpointer should consider |
129 // long_speech_input_complete_silence_length_ as a valid silence period | 130 // long_speech_input_complete_silence_length_ as a valid silence period |
130 // instead of speech_input_complete_silence_length_. This parameter is | 131 // instead of speech_input_complete_silence_length_. This parameter is |
131 // optional. | 132 // optional. |
132 int64 long_speech_length_us_; | 133 int64_t long_speech_length_us_; |
133 | 134 |
134 // First speech onset time, used in determination of speech complete timeout. | 135 // First speech onset time, used in determination of speech complete timeout. |
135 int64 speech_start_time_us_; | 136 int64_t speech_start_time_us_; |
136 | 137 |
137 // Most recent end time, used in determination of speech complete timeout. | 138 // Most recent end time, used in determination of speech complete timeout. |
138 int64 speech_end_time_us_; | 139 int64_t speech_end_time_us_; |
139 | 140 |
140 int64 audio_frame_time_us_; | 141 int64_t audio_frame_time_us_; |
141 EpStatus old_ep_status_; | 142 EpStatus old_ep_status_; |
142 bool waiting_for_speech_possibly_complete_timeout_; | 143 bool waiting_for_speech_possibly_complete_timeout_; |
143 bool waiting_for_speech_complete_timeout_; | 144 bool waiting_for_speech_complete_timeout_; |
144 bool speech_previously_detected_; | 145 bool speech_previously_detected_; |
145 bool speech_input_complete_; | 146 bool speech_input_complete_; |
146 EnergyEndpointer energy_endpointer_; | 147 EnergyEndpointer energy_endpointer_; |
147 int sample_rate_; | 148 int sample_rate_; |
148 int32 frame_size_; | 149 int32_t frame_size_; |
149 }; | 150 }; |
150 | 151 |
151 } // namespace content | 152 } // namespace content |
152 | 153 |
153 #endif // CONTENT_BROWSER_SPEECH_ENDPOINTER_ENDPOINTER_H_ | 154 #endif // CONTENT_BROWSER_SPEECH_ENDPOINTER_ENDPOINTER_H_ |
OLD | NEW |