diff options
author | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-07 13:29:35 +0000 |
---|---|---|
committer | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-07 13:29:35 +0000 |
commit | d1ecb010a30afb74dfd33294771c9a1559f62141 (patch) | |
tree | 259e50648ff9445ff7c43f713c960a31f55e7b2b /content/browser/speech/speech_recognizer.h | |
parent | b773cee71532fbce19c1b92f256a950979764c8c (diff) | |
download | chromium_src-d1ecb010a30afb74dfd33294771c9a1559f62141.zip chromium_src-d1ecb010a30afb74dfd33294771c9a1559f62141.tar.gz chromium_src-d1ecb010a30afb74dfd33294771c9a1559f62141.tar.bz2 |
Applying changes to the existing speech input code to support the extension API.
This includes extended error management by handling the status response code and the DidStartReceivingSpeech/DidStopReceivingSpeech events.
BUG=97388
TEST=none
Review URL: http://codereview.chromium.org/8137005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104471 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/speech/speech_recognizer.h')
-rw-r--r-- | content/browser/speech/speech_recognizer.h | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/content/browser/speech/speech_recognizer.h b/content/browser/speech/speech_recognizer.h index bd1c8e4..1e3061a 100644 --- a/content/browser/speech/speech_recognizer.h +++ b/content/browser/speech/speech_recognizer.h @@ -30,21 +30,12 @@ class CONTENT_EXPORT SpeechRecognizer public media::AudioInputController::EventHandler, public SpeechRecognitionRequestDelegate { public: - enum ErrorCode { - RECOGNIZER_NO_ERROR, - RECOGNIZER_ERROR_CAPTURE, - RECOGNIZER_ERROR_NO_SPEECH, - RECOGNIZER_ERROR_NO_RESULTS, - RECOGNIZER_ERROR_NETWORK, - }; - // Implemented by the caller to receive recognition events. class CONTENT_EXPORT Delegate { public: virtual void SetRecognitionResult( int caller_id, - bool error, - const SpeechInputResultArray& result) = 0; + const SpeechInputResult& result) = 0; // Invoked when the first audio packet was received from the audio capture // device. @@ -60,12 +51,18 @@ class CONTENT_EXPORT SpeechRecognizer // sequence and the |SpeechRecognizer| object can be freed up if necessary. virtual void DidCompleteRecognition(int caller_id) = 0; + // Informs that the end pointer has started detecting speech. + virtual void DidStartReceivingSpeech(int caller_id) = 0; + + // Informs that the end pointer has stopped detecting speech. + virtual void DidStopReceivingSpeech(int caller_id) = 0; + // Invoked if there was an error while recording or recognizing audio. The // session has already been cancelled when this call is made and the DidXxxx // callbacks will not be issued. It is safe to destroy/release the // |SpeechRecognizer| object while processing this call. virtual void OnRecognizerError(int caller_id, - SpeechRecognizer::ErrorCode error) = 0; + SpeechInputError error) = 0; // At the start of recognition, a short amount of audio is recorded to // estimate the environment/background noise and this callback is issued @@ -91,6 +88,7 @@ class CONTENT_EXPORT SpeechRecognizer bool censor_results, const std::string& hardware_info, const std::string& origin_url); + virtual ~SpeechRecognizer(); // Starts audio recording and does recognition after recording ends. The same @@ -115,8 +113,7 @@ class CONTENT_EXPORT SpeechRecognizer uint32 size); // SpeechRecognitionRequest::Delegate methods. - virtual void SetRecognitionResult(bool error, - const SpeechInputResultArray& result); + virtual void SetRecognitionResult(const SpeechInputResult& result); static const int kAudioSampleRate; static const int kAudioPacketIntervalMs; // Duration of each audio packet. @@ -126,7 +123,7 @@ class CONTENT_EXPORT SpeechRecognizer static const int kEndpointerEstimationTimeMs; private: - void InformErrorAndCancelRecognition(ErrorCode error); + void InformErrorAndCancelRecognition(SpeechInputError error); void SendRecordedAudioToServer(); void HandleOnError(int error_code); // Handles OnError in the IO thread. |