OLD | NEW |
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 #ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ |
6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ | 6 #define CHROME_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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 virtual void SetInputVolume(int caller_id, float volume) = 0; | 69 virtual void SetInputVolume(int caller_id, float volume) = 0; |
70 | 70 |
71 protected: | 71 protected: |
72 virtual ~Delegate() {} | 72 virtual ~Delegate() {} |
73 }; | 73 }; |
74 | 74 |
75 SpeechRecognizer(Delegate* delegate, | 75 SpeechRecognizer(Delegate* delegate, |
76 int caller_id, | 76 int caller_id, |
77 const std::string& language, | 77 const std::string& language, |
78 const std::string& grammar, | 78 const std::string& grammar, |
79 const std::string& hardware_info); | 79 const std::string& hardware_info, |
| 80 const std::string& origin_url); |
80 ~SpeechRecognizer(); | 81 ~SpeechRecognizer(); |
81 | 82 |
82 // Starts audio recording and does recognition after recording ends. The same | 83 // Starts audio recording and does recognition after recording ends. The same |
83 // SpeechRecognizer instance can be used multiple times for speech recognition | 84 // SpeechRecognizer instance can be used multiple times for speech recognition |
84 // though each recognition request can be made only after the previous one | 85 // though each recognition request can be made only after the previous one |
85 // completes (i.e. after receiving Delegate::DidCompleteRecognition). | 86 // completes (i.e. after receiving Delegate::DidCompleteRecognition). |
86 bool StartRecording(); | 87 bool StartRecording(); |
87 | 88 |
88 // Stops recording audio and starts recognition. | 89 // Stops recording audio and starts recognition. |
89 void StopRecording(); | 90 void StopRecording(); |
(...skipping 29 matching lines...) Expand all Loading... |
119 void HandleOnError(int error_code); // Handles OnError in the IO thread. | 120 void HandleOnError(int error_code); // Handles OnError in the IO thread. |
120 | 121 |
121 // Handles OnData in the IO thread. Takes ownership of |data|. | 122 // Handles OnData in the IO thread. Takes ownership of |data|. |
122 void HandleOnData(std::string* data); | 123 void HandleOnData(std::string* data); |
123 | 124 |
124 Delegate* delegate_; | 125 Delegate* delegate_; |
125 int caller_id_; | 126 int caller_id_; |
126 std::string language_; | 127 std::string language_; |
127 std::string grammar_; | 128 std::string grammar_; |
128 std::string hardware_info_; | 129 std::string hardware_info_; |
| 130 std::string origin_url_; |
129 | 131 |
130 scoped_ptr<SpeechRecognitionRequest> request_; | 132 scoped_ptr<SpeechRecognitionRequest> request_; |
131 scoped_refptr<media::AudioInputController> audio_controller_; | 133 scoped_refptr<media::AudioInputController> audio_controller_; |
132 AudioEncoder::Codec codec_; | 134 AudioEncoder::Codec codec_; |
133 scoped_ptr<AudioEncoder> encoder_; | 135 scoped_ptr<AudioEncoder> encoder_; |
134 Endpointer endpointer_; | 136 Endpointer endpointer_; |
135 int num_samples_recorded_; | 137 int num_samples_recorded_; |
136 float audio_level_; | 138 float audio_level_; |
137 | 139 |
138 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer); | 140 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer); |
139 }; | 141 }; |
140 | 142 |
141 // This typedef is to workaround the issue with certain versions of | 143 // This typedef is to workaround the issue with certain versions of |
142 // Visual Studio where it gets confused between multiple Delegate | 144 // Visual Studio where it gets confused between multiple Delegate |
143 // classes and gives a C2500 error. (I saw this error on the try bots - | 145 // classes and gives a C2500 error. (I saw this error on the try bots - |
144 // the workaround was not needed for my machine). | 146 // the workaround was not needed for my machine). |
145 typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate; | 147 typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate; |
146 | 148 |
147 } // namespace speech_input | 149 } // namespace speech_input |
148 | 150 |
149 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ | 151 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ |
OLD | NEW |