| 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 18 matching lines...) Expand all Loading... |
| 29 enum ErrorCode { | 29 enum ErrorCode { |
| 30 RECOGNIZER_NO_ERROR, | 30 RECOGNIZER_NO_ERROR, |
| 31 RECOGNIZER_ERROR_CAPTURE, | 31 RECOGNIZER_ERROR_CAPTURE, |
| 32 RECOGNIZER_ERROR_NO_SPEECH, | 32 RECOGNIZER_ERROR_NO_SPEECH, |
| 33 RECOGNIZER_ERROR_NO_RESULTS, | 33 RECOGNIZER_ERROR_NO_RESULTS, |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 // Implemented by the caller to receive recognition events. | 36 // Implemented by the caller to receive recognition events. |
| 37 class Delegate { | 37 class Delegate { |
| 38 public: | 38 public: |
| 39 virtual void SetRecognitionResult(int caller_id, | 39 virtual void SetRecognitionResult( |
| 40 bool error, | 40 int caller_id, |
| 41 const string16& value) = 0; | 41 bool error, |
| 42 const SpeechInputResultArray& result) = 0; |
| 42 | 43 |
| 43 // Invoked when audio recording stops, either due to the end pointer | 44 // Invoked when audio recording stops, either due to the end pointer |
| 44 // detecting silence in user input or if |StopRecording| was called. The | 45 // detecting silence in user input or if |StopRecording| was called. The |
| 45 // delegate has to wait until |DidCompleteRecognition| is invoked before | 46 // delegate has to wait until |DidCompleteRecognition| is invoked before |
| 46 // destroying the |SpeechRecognizer| object. | 47 // destroying the |SpeechRecognizer| object. |
| 47 virtual void DidCompleteRecording(int caller_id) = 0; | 48 virtual void DidCompleteRecording(int caller_id) = 0; |
| 48 | 49 |
| 49 // This is guaranteed to be the last method invoked in the recognition | 50 // This is guaranteed to be the last method invoked in the recognition |
| 50 // sequence and the |SpeechRecognizer| object can be freed up if necessary. | 51 // sequence and the |SpeechRecognizer| object can be freed up if necessary. |
| 51 virtual void DidCompleteRecognition(int caller_id) = 0; | 52 virtual void DidCompleteRecognition(int caller_id) = 0; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 void CancelRecognition(); | 90 void CancelRecognition(); |
| 90 | 91 |
| 91 // AudioInputController::EventHandler methods. | 92 // AudioInputController::EventHandler methods. |
| 92 void OnCreated(media::AudioInputController* controller) { } | 93 void OnCreated(media::AudioInputController* controller) { } |
| 93 void OnRecording(media::AudioInputController* controller) { } | 94 void OnRecording(media::AudioInputController* controller) { } |
| 94 void OnError(media::AudioInputController* controller, int error_code); | 95 void OnError(media::AudioInputController* controller, int error_code); |
| 95 void OnData(media::AudioInputController* controller, const uint8* data, | 96 void OnData(media::AudioInputController* controller, const uint8* data, |
| 96 uint32 size); | 97 uint32 size); |
| 97 | 98 |
| 98 // SpeechRecognitionRequest::Delegate methods. | 99 // SpeechRecognitionRequest::Delegate methods. |
| 99 void SetRecognitionResult(bool error, const string16& value); | 100 void SetRecognitionResult(bool error, const SpeechInputResultArray& result); |
| 100 | 101 |
| 101 static const int kAudioSampleRate; | 102 static const int kAudioSampleRate; |
| 102 static const int kAudioPacketIntervalMs; // Duration of each audio packet. | 103 static const int kAudioPacketIntervalMs; // Duration of each audio packet. |
| 103 static const int kNumAudioChannels; | 104 static const int kNumAudioChannels; |
| 104 static const int kNumBitsPerAudioSample; | 105 static const int kNumBitsPerAudioSample; |
| 105 static const int kNoSpeechTimeoutSec; | 106 static const int kNoSpeechTimeoutSec; |
| 106 static const int kEndpointerEstimationTimeMs; | 107 static const int kEndpointerEstimationTimeMs; |
| 107 | 108 |
| 108 private: | 109 private: |
| 109 void ReleaseAudioBuffers(); | 110 void ReleaseAudioBuffers(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 133 | 134 |
| 134 // This typedef is to workaround the issue with certain versions of | 135 // This typedef is to workaround the issue with certain versions of |
| 135 // Visual Studio where it gets confused between multiple Delegate | 136 // Visual Studio where it gets confused between multiple Delegate |
| 136 // classes and gives a C2500 error. (I saw this error on the try bots - | 137 // classes and gives a C2500 error. (I saw this error on the try bots - |
| 137 // the workaround was not needed for my machine). | 138 // the workaround was not needed for my machine). |
| 138 typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate; | 139 typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate; |
| 139 | 140 |
| 140 } // namespace speech_input | 141 } // namespace speech_input |
| 141 | 142 |
| 142 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ | 143 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ |
| OLD | NEW |