| 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_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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 EVENT_ENGINE_ERROR, | 74 EVENT_ENGINE_ERROR, |
| 75 EVENT_AUDIO_ERROR, | 75 EVENT_AUDIO_ERROR, |
| 76 EVENT_MAX_VALUE = EVENT_AUDIO_ERROR | 76 EVENT_MAX_VALUE = EVENT_AUDIO_ERROR |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 struct FSMEventArgs { | 79 struct FSMEventArgs { |
| 80 explicit FSMEventArgs(FSMEvent event_value); | 80 explicit FSMEventArgs(FSMEvent event_value); |
| 81 ~FSMEventArgs(); | 81 ~FSMEventArgs(); |
| 82 | 82 |
| 83 FSMEvent event; | 83 FSMEvent event; |
| 84 int audio_error_code; | |
| 85 scoped_refptr<AudioChunk> audio_data; | 84 scoped_refptr<AudioChunk> audio_data; |
| 86 SpeechRecognitionResults engine_results; | 85 SpeechRecognitionResults engine_results; |
| 87 SpeechRecognitionError engine_error; | 86 SpeechRecognitionError engine_error; |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 virtual ~SpeechRecognizer(); | 89 virtual ~SpeechRecognizer(); |
| 91 | 90 |
| 92 // Entry point for pushing any new external event into the recognizer FSM. | 91 // Entry point for pushing any new external event into the recognizer FSM. |
| 93 void DispatchEvent(const FSMEventArgs& event_args); | 92 void DispatchEvent(const FSMEventArgs& event_args); |
| 94 | 93 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 122 void UpdateSignalAndNoiseLevels(const float& rms, bool clip_detected); | 121 void UpdateSignalAndNoiseLevels(const float& rms, bool clip_detected); |
| 123 | 122 |
| 124 void CloseAudioControllerAsynchronously(); | 123 void CloseAudioControllerAsynchronously(); |
| 125 | 124 |
| 126 // Callback called on IO thread by audio_controller->Close(). | 125 // Callback called on IO thread by audio_controller->Close(). |
| 127 void OnAudioClosed(media::AudioInputController*); | 126 void OnAudioClosed(media::AudioInputController*); |
| 128 | 127 |
| 129 // AudioInputController::EventHandler methods. | 128 // AudioInputController::EventHandler methods. |
| 130 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE {} | 129 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE {} |
| 131 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE {} | 130 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE {} |
| 132 virtual void OnError(media::AudioInputController* controller, | 131 virtual void OnError(media::AudioInputController* controller) OVERRIDE; |
| 133 int error_code) OVERRIDE; | |
| 134 virtual void OnData(media::AudioInputController* controller, | 132 virtual void OnData(media::AudioInputController* controller, |
| 135 const uint8* data, uint32 size) OVERRIDE; | 133 const uint8* data, uint32 size) OVERRIDE; |
| 136 | 134 |
| 137 // SpeechRecognitionEngineDelegate methods. | 135 // SpeechRecognitionEngineDelegate methods. |
| 138 virtual void OnSpeechRecognitionEngineResults( | 136 virtual void OnSpeechRecognitionEngineResults( |
| 139 const SpeechRecognitionResults& results) OVERRIDE; | 137 const SpeechRecognitionResults& results) OVERRIDE; |
| 140 virtual void OnSpeechRecognitionEngineError( | 138 virtual void OnSpeechRecognitionEngineError( |
| 141 const SpeechRecognitionError& error) OVERRIDE; | 139 const SpeechRecognitionError& error) OVERRIDE; |
| 142 | 140 |
| 143 static media::AudioManager* audio_manager_for_tests_; | 141 static media::AudioManager* audio_manager_for_tests_; |
| 144 | 142 |
| 145 SpeechRecognitionEventListener* listener_; | 143 SpeechRecognitionEventListener* listener_; |
| 146 scoped_ptr<SpeechRecognitionEngine> recognition_engine_; | 144 scoped_ptr<SpeechRecognitionEngine> recognition_engine_; |
| 147 Endpointer endpointer_; | 145 Endpointer endpointer_; |
| 148 scoped_refptr<media::AudioInputController> audio_controller_; | 146 scoped_refptr<media::AudioInputController> audio_controller_; |
| 149 int session_id_; | 147 int session_id_; |
| 150 int num_samples_recorded_; | 148 int num_samples_recorded_; |
| 151 float audio_level_; | 149 float audio_level_; |
| 152 bool is_dispatching_event_; | 150 bool is_dispatching_event_; |
| 153 bool is_single_shot_; | 151 bool is_single_shot_; |
| 154 FSMState state_; | 152 FSMState state_; |
| 155 | 153 |
| 156 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer); | 154 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer); |
| 157 }; | 155 }; |
| 158 | 156 |
| 159 } // namespace content | 157 } // namespace content |
| 160 | 158 |
| 161 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ | 159 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ |
| OLD | NEW |