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 "media/audio/audio_input_controller.h" | 15 #include "media/audio/audio_input_controller.h" |
16 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class SpeechRecognitionEventListener; | 19 class SpeechRecognitionEventListener; |
20 struct SpeechRecognitionResult; | 20 struct SpeechRecognitionResult; |
21 } | 21 } |
22 | 22 |
23 namespace media { | 23 namespace media { |
24 class AudioInputController; | 24 class AudioInputController; |
| 25 class AudioManager; |
25 } | 26 } |
26 | 27 |
27 namespace speech { | 28 namespace speech { |
28 | 29 |
29 // Records audio, sends recorded audio to server and translates server response | 30 // Records audio, sends recorded audio to server and translates server response |
30 // to recognition result. | 31 // to recognition result. |
31 class CONTENT_EXPORT SpeechRecognizerImpl | 32 class CONTENT_EXPORT SpeechRecognizerImpl |
32 : public NON_EXPORTED_BASE(content::SpeechRecognizer), | 33 : public NON_EXPORTED_BASE(content::SpeechRecognizer), |
33 public media::AudioInputController::EventHandler, | 34 public media::AudioInputController::EventHandler, |
34 public NON_EXPORTED_BASE(SpeechRecognitionEngineDelegate) { | 35 public NON_EXPORTED_BASE(SpeechRecognitionEngineDelegate) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 85 |
85 // Handles OnData in the IO thread. | 86 // Handles OnData in the IO thread. |
86 void HandleOnData(scoped_refptr<AudioChunk> raw_audio); | 87 void HandleOnData(scoped_refptr<AudioChunk> raw_audio); |
87 | 88 |
88 void OnAudioClosed(media::AudioInputController*); | 89 void OnAudioClosed(media::AudioInputController*); |
89 | 90 |
90 // Helper method which closes the audio controller and frees it asynchronously | 91 // Helper method which closes the audio controller and frees it asynchronously |
91 // without blocking the IO thread. | 92 // without blocking the IO thread. |
92 void CloseAudioControllerAsynchronously(); | 93 void CloseAudioControllerAsynchronously(); |
93 | 94 |
94 void SetAudioManagerForTesting(AudioManager* audio_manager); | 95 void SetAudioManagerForTesting(media::AudioManager* audio_manager); |
95 | 96 |
96 content::SpeechRecognitionEventListener* listener_; | 97 content::SpeechRecognitionEventListener* listener_; |
97 AudioManager* testing_audio_manager_; | 98 media::AudioManager* testing_audio_manager_; |
98 scoped_ptr<SpeechRecognitionEngine> recognition_engine_; | 99 scoped_ptr<SpeechRecognitionEngine> recognition_engine_; |
99 Endpointer endpointer_; | 100 Endpointer endpointer_; |
100 scoped_refptr<media::AudioInputController> audio_controller_; | 101 scoped_refptr<media::AudioInputController> audio_controller_; |
101 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 102 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
102 int caller_id_; | 103 int caller_id_; |
103 std::string language_; | 104 std::string language_; |
104 std::string grammar_; | 105 std::string grammar_; |
105 bool filter_profanities_; | 106 bool filter_profanities_; |
106 std::string hardware_info_; | 107 std::string hardware_info_; |
107 std::string origin_url_; | 108 std::string origin_url_; |
108 int num_samples_recorded_; | 109 int num_samples_recorded_; |
109 float audio_level_; | 110 float audio_level_; |
110 | 111 |
111 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); | 112 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); |
112 }; | 113 }; |
113 | 114 |
114 } // namespace speech | 115 } // namespace speech |
115 | 116 |
116 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ | 117 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ |
OLD | NEW |