OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SPEECH_RECOGNIZER_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ |
6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ | 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 protected: | 79 protected: |
80 virtual ~Delegate() {} | 80 virtual ~Delegate() {} |
81 }; | 81 }; |
82 | 82 |
83 SpeechRecognizer(Delegate* delegate, | 83 SpeechRecognizer(Delegate* delegate, |
84 int caller_id, | 84 int caller_id, |
85 const std::string& language, | 85 const std::string& language, |
86 const std::string& grammar, | 86 const std::string& grammar, |
87 net::URLRequestContextGetter* context_getter, | 87 net::URLRequestContextGetter* context_getter, |
88 bool censor_results, | 88 bool filter_profanities, |
89 const std::string& hardware_info, | 89 const std::string& hardware_info, |
90 const std::string& origin_url); | 90 const std::string& origin_url); |
91 | 91 |
92 virtual ~SpeechRecognizer(); | 92 virtual ~SpeechRecognizer(); |
93 | 93 |
94 // Starts audio recording and does recognition after recording ends. The same | 94 // Starts audio recording and does recognition after recording ends. The same |
95 // SpeechRecognizer instance can be used multiple times for speech recognition | 95 // SpeechRecognizer instance can be used multiple times for speech recognition |
96 // though each recognition request can be made only after the previous one | 96 // though each recognition request can be made only after the previous one |
97 // completes (i.e. after receiving Delegate::DidCompleteRecognition). | 97 // completes (i.e. after receiving Delegate::DidCompleteRecognition). |
98 bool StartRecording(); | 98 bool StartRecording(); |
(...skipping 29 matching lines...) Expand all Loading... |
128 | 128 |
129 void HandleOnError(int error_code); // Handles OnError in the IO thread. | 129 void HandleOnError(int error_code); // Handles OnError in the IO thread. |
130 | 130 |
131 // Handles OnData in the IO thread. Takes ownership of |data|. | 131 // Handles OnData in the IO thread. Takes ownership of |data|. |
132 void HandleOnData(std::string* data); | 132 void HandleOnData(std::string* data); |
133 | 133 |
134 Delegate* delegate_; | 134 Delegate* delegate_; |
135 int caller_id_; | 135 int caller_id_; |
136 std::string language_; | 136 std::string language_; |
137 std::string grammar_; | 137 std::string grammar_; |
138 bool censor_results_; | 138 bool filter_profanities_; |
139 std::string hardware_info_; | 139 std::string hardware_info_; |
140 std::string origin_url_; | 140 std::string origin_url_; |
141 | 141 |
142 scoped_ptr<SpeechRecognitionRequest> request_; | 142 scoped_ptr<SpeechRecognitionRequest> request_; |
143 scoped_refptr<media::AudioInputController> audio_controller_; | 143 scoped_refptr<media::AudioInputController> audio_controller_; |
144 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 144 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
145 AudioEncoder::Codec codec_; | 145 AudioEncoder::Codec codec_; |
146 scoped_ptr<AudioEncoder> encoder_; | 146 scoped_ptr<AudioEncoder> encoder_; |
147 Endpointer endpointer_; | 147 Endpointer endpointer_; |
148 int num_samples_recorded_; | 148 int num_samples_recorded_; |
149 float audio_level_; | 149 float audio_level_; |
150 | 150 |
151 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer); | 151 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer); |
152 }; | 152 }; |
153 | 153 |
154 // This typedef is to workaround the issue with certain versions of | 154 // This typedef is to workaround the issue with certain versions of |
155 // Visual Studio where it gets confused between multiple Delegate | 155 // Visual Studio where it gets confused between multiple Delegate |
156 // classes and gives a C2500 error. (I saw this error on the try bots - | 156 // classes and gives a C2500 error. (I saw this error on the try bots - |
157 // the workaround was not needed for my machine). | 157 // the workaround was not needed for my machine). |
158 typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate; | 158 typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate; |
159 | 159 |
160 } // namespace speech_input | 160 } // namespace speech_input |
161 | 161 |
162 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ | 162 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ |
OLD | NEW |