Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: content/browser/speech/speech_recognizer.h

Issue 7969028: Reland r102332 - export more symbols needed for the component build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: actual fix for compile failure Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/speech/speech_recognition_request.h ('k') | content/renderer/render_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "content/browser/speech/audio_encoder.h" 14 #include "content/browser/speech/audio_encoder.h"
15 #include "content/browser/speech/endpointer/endpointer.h" 15 #include "content/browser/speech/endpointer/endpointer.h"
16 #include "content/browser/speech/speech_recognition_request.h" 16 #include "content/browser/speech/speech_recognition_request.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "media/audio/audio_input_controller.h" 18 #include "media/audio/audio_input_controller.h"
19 19
20 namespace speech_input { 20 namespace speech_input {
21 21
22 // Records audio, sends recorded audio to server and translates server response 22 // Records audio, sends recorded audio to server and translates server response
23 // to recognition result. 23 // to recognition result.
24 class SpeechRecognizer 24 class CONTENT_EXPORT SpeechRecognizer
25 : public base::RefCountedThreadSafe<SpeechRecognizer>, 25 : public base::RefCountedThreadSafe<SpeechRecognizer>,
26 public media::AudioInputController::EventHandler, 26 public media::AudioInputController::EventHandler,
27 public SpeechRecognitionRequestDelegate { 27 public SpeechRecognitionRequestDelegate {
28 public: 28 public:
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 RECOGNIZER_ERROR_NETWORK, 34 RECOGNIZER_ERROR_NETWORK,
35 }; 35 };
36 36
37 // Implemented by the caller to receive recognition events. 37 // Implemented by the caller to receive recognition events.
38 class Delegate { 38 class CONTENT_EXPORT Delegate {
39 public: 39 public:
40 virtual void SetRecognitionResult( 40 virtual void SetRecognitionResult(
41 int caller_id, 41 int caller_id,
42 bool error, 42 bool error,
43 const SpeechInputResultArray& result) = 0; 43 const SpeechInputResultArray& result) = 0;
44 44
45 // Invoked when the first audio packet was received from the audio capture 45 // Invoked when the first audio packet was received from the audio capture
46 // device. 46 // device.
47 virtual void DidStartReceivingAudio(int caller_id) = 0; 47 virtual void DidStartReceivingAudio(int caller_id) = 0;
48 48
(...skipping 23 matching lines...) Expand all
72 // Informs of a change in the captured audio level, useful if displaying 72 // Informs of a change in the captured audio level, useful if displaying
73 // a microphone volume indicator while recording. 73 // a microphone volume indicator while recording.
74 // The value of |volume| and |noise_volume| is in the [0.0, 1.0] range. 74 // The value of |volume| and |noise_volume| is in the [0.0, 1.0] range.
75 virtual void SetInputVolume(int caller_id, float volume, 75 virtual void SetInputVolume(int caller_id, float volume,
76 float noise_volume) = 0; 76 float noise_volume) = 0;
77 77
78 protected: 78 protected:
79 virtual ~Delegate() {} 79 virtual ~Delegate() {}
80 }; 80 };
81 81
82 CONTENT_EXPORT SpeechRecognizer(Delegate* delegate, 82 SpeechRecognizer(Delegate* delegate,
83 int caller_id, 83 int caller_id,
84 const std::string& language, 84 const std::string& language,
85 const std::string& grammar, 85 const std::string& grammar,
86 bool censor_results, 86 bool censor_results,
87 const std::string& hardware_info, 87 const std::string& hardware_info,
88 const std::string& origin_url); 88 const std::string& origin_url);
89 virtual ~SpeechRecognizer(); 89 virtual ~SpeechRecognizer();
90 90
91 // Starts audio recording and does recognition after recording ends. The same 91 // Starts audio recording and does recognition after recording ends. The same
92 // SpeechRecognizer instance can be used multiple times for speech recognition 92 // SpeechRecognizer instance can be used multiple times for speech recognition
93 // though each recognition request can be made only after the previous one 93 // though each recognition request can be made only after the previous one
94 // completes (i.e. after receiving Delegate::DidCompleteRecognition). 94 // completes (i.e. after receiving Delegate::DidCompleteRecognition).
95 CONTENT_EXPORT bool StartRecording(); 95 bool StartRecording();
96 96
97 // Stops recording audio and starts recognition. 97 // Stops recording audio and starts recognition.
98 CONTENT_EXPORT void StopRecording(); 98 void StopRecording();
99 99
100 // Stops recording audio and cancels recognition. Any audio recorded so far 100 // Stops recording audio and cancels recognition. Any audio recorded so far
101 // gets discarded. 101 // gets discarded.
102 CONTENT_EXPORT void CancelRecognition(); 102 void CancelRecognition();
103 103
104 // AudioInputController::EventHandler methods. 104 // AudioInputController::EventHandler methods.
105 virtual void OnCreated(media::AudioInputController* controller) { } 105 virtual void OnCreated(media::AudioInputController* controller) { }
106 virtual void OnRecording(media::AudioInputController* controller) { } 106 virtual void OnRecording(media::AudioInputController* controller) { }
107 virtual void OnError(media::AudioInputController* controller, int error_code); 107 virtual void OnError(media::AudioInputController* controller, int error_code);
108 virtual void OnData(media::AudioInputController* controller, 108 virtual void OnData(media::AudioInputController* controller,
109 const uint8* data, 109 const uint8* data,
110 uint32 size); 110 uint32 size);
111 111
112 // SpeechRecognitionRequest::Delegate methods. 112 // SpeechRecognitionRequest::Delegate methods.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 // This typedef is to workaround the issue with certain versions of 151 // This typedef is to workaround the issue with certain versions of
152 // Visual Studio where it gets confused between multiple Delegate 152 // Visual Studio where it gets confused between multiple Delegate
153 // classes and gives a C2500 error. (I saw this error on the try bots - 153 // classes and gives a C2500 error. (I saw this error on the try bots -
154 // the workaround was not needed for my machine). 154 // the workaround was not needed for my machine).
155 typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate; 155 typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate;
156 156
157 } // namespace speech_input 157 } // namespace speech_input
158 158
159 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ 159 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_
OLDNEW
« no previous file with comments | « content/browser/speech/speech_recognition_request.h ('k') | content/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698