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