Chromium Code Reviews| 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_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ | 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_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" |
| 11 #include "content/browser/speech/endpointer/endpointer.h" | 11 #include "content/browser/speech/endpointer/endpointer.h" |
| 12 #include "content/browser/speech/speech_recognition_engine.h" | 12 #include "content/browser/speech/speech_recognition_engine.h" |
| 13 #include "content/public/browser/speech_recognizer.h" | 13 #include "content/public/browser/speech_recognizer.h" |
| 14 #include "content/public/common/speech_recognition_error.h" | 14 #include "content/public/common/speech_recognition_error.h" |
| 15 #include "content/public/common/speech_recognition_result.h" | 15 #include "content/public/common/speech_recognition_result.h" |
| 16 #include "media/audio/audio_input_controller.h" | 16 #include "media/audio/audio_input_controller.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class SpeechRecognitionEventListener; | 20 class SpeechRecognitionEventListener; |
| 21 struct SpeechRecognitionResult; | |
| 22 } | 21 } |
| 23 | 22 |
| 24 namespace media { | 23 namespace media { |
| 25 class AudioInputController; | |
| 26 class AudioManager; | 24 class AudioManager; |
| 27 } | 25 } |
| 28 | 26 |
| 29 namespace speech { | 27 namespace speech { |
| 30 | 28 |
| 31 // TODO(primiano) Next CL: Remove the Impl suffix and the exported | 29 // TODO(primiano) Next CL: Remove the Impl suffix and the exported |
| 32 // /content/public/browser/speech_recognizer.h interface since this class should | 30 // /content/public/browser/speech_recognizer.h interface since this class should |
| 33 // not be visible outside (currently we need it for speech input extension API). | 31 // not be visible outside (currently we need it for speech input extension API). |
| 34 | 32 |
| 35 // Handles speech recognition for a session (identified by |caller_id|), taking | 33 // Handles speech recognition for a session (identified by |session_id|), taking |
|
hans
2012/04/17 00:00:11
i like how the new variable name fits in with this
| |
| 36 // care of audio capture, silence detection/endpointer and interaction with the | 34 // care of audio capture, silence detection/endpointer and interaction with the |
| 37 // SpeechRecognitionEngine. | 35 // SpeechRecognitionEngine. |
| 38 class CONTENT_EXPORT SpeechRecognizerImpl | 36 class CONTENT_EXPORT SpeechRecognizerImpl |
| 39 : public NON_EXPORTED_BASE(content::SpeechRecognizer), | 37 : public NON_EXPORTED_BASE(content::SpeechRecognizer), |
| 40 public media::AudioInputController::EventHandler, | 38 public media::AudioInputController::EventHandler, |
| 41 public NON_EXPORTED_BASE(SpeechRecognitionEngineDelegate) { | 39 public NON_EXPORTED_BASE(SpeechRecognitionEngineDelegate) { |
| 42 public: | 40 public: |
| 43 static const int kAudioSampleRate; | 41 static const int kAudioSampleRate; |
| 44 static const ChannelLayout kChannelLayout; | 42 static const ChannelLayout kChannelLayout; |
| 45 static const int kNumBitsPerAudioSample; | 43 static const int kNumBitsPerAudioSample; |
| 46 static const int kNoSpeechTimeoutMs; | 44 static const int kNoSpeechTimeoutMs; |
| 47 static const int kEndpointerEstimationTimeMs; | 45 static const int kEndpointerEstimationTimeMs; |
| 48 | 46 |
| 49 SpeechRecognizerImpl( | 47 SpeechRecognizerImpl( |
| 50 content::SpeechRecognitionEventListener* listener, | 48 content::SpeechRecognitionEventListener* listener, |
| 51 int caller_id, | 49 int session_id, |
| 52 SpeechRecognitionEngine* engine); | 50 SpeechRecognitionEngine* engine); |
| 53 virtual ~SpeechRecognizerImpl(); | 51 virtual ~SpeechRecognizerImpl(); |
| 54 | 52 |
| 55 // content::SpeechRecognizer methods. | 53 // content::SpeechRecognizer methods. |
| 56 virtual void StartRecognition() OVERRIDE; | 54 virtual void StartRecognition() OVERRIDE; |
| 57 virtual void AbortRecognition() OVERRIDE; | 55 virtual void AbortRecognition() OVERRIDE; |
| 58 virtual void StopAudioCapture() OVERRIDE; | 56 virtual void StopAudioCapture() OVERRIDE; |
| 59 virtual bool IsActive() const OVERRIDE; | 57 virtual bool IsActive() const OVERRIDE; |
| 60 virtual bool IsCapturingAudio() const OVERRIDE; | 58 virtual bool IsCapturingAudio() const OVERRIDE; |
| 61 const SpeechRecognitionEngine& recognition_engine() const; | 59 const SpeechRecognitionEngine& recognition_engine() const; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 virtual void OnSpeechRecognitionEngineResult( | 143 virtual void OnSpeechRecognitionEngineResult( |
| 146 const content::SpeechRecognitionResult& result) OVERRIDE; | 144 const content::SpeechRecognitionResult& result) OVERRIDE; |
| 147 virtual void OnSpeechRecognitionEngineError( | 145 virtual void OnSpeechRecognitionEngineError( |
| 148 const content::SpeechRecognitionError& error) OVERRIDE; | 146 const content::SpeechRecognitionError& error) OVERRIDE; |
| 149 | 147 |
| 150 content::SpeechRecognitionEventListener* listener_; | 148 content::SpeechRecognitionEventListener* listener_; |
| 151 media::AudioManager* testing_audio_manager_; | 149 media::AudioManager* testing_audio_manager_; |
| 152 scoped_ptr<SpeechRecognitionEngine> recognition_engine_; | 150 scoped_ptr<SpeechRecognitionEngine> recognition_engine_; |
| 153 Endpointer endpointer_; | 151 Endpointer endpointer_; |
| 154 scoped_refptr<media::AudioInputController> audio_controller_; | 152 scoped_refptr<media::AudioInputController> audio_controller_; |
| 155 int caller_id_; | 153 int session_id_; |
| 156 int num_samples_recorded_; | 154 int num_samples_recorded_; |
| 157 float audio_level_; | 155 float audio_level_; |
| 158 bool is_dispatching_event_; | 156 bool is_dispatching_event_; |
| 159 FSMState state_; | 157 FSMState state_; |
| 160 | 158 |
| 161 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); | 159 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); |
| 162 }; | 160 }; |
| 163 | 161 |
| 164 } // namespace speech | 162 } // namespace speech |
| 165 | 163 |
| 166 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ | 164 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ |
| OLD | NEW |