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

Unified Diff: chrome/browser/speech/speech_input_manager.cc

Issue 3341020: Speech input: Do environment estimation and detect the no-speech case. (Closed)
Patch Set: . Created 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/speech/speech_input_manager.cc
diff --git a/chrome/browser/speech/speech_input_manager.cc b/chrome/browser/speech/speech_input_manager.cc
index 707f85516b342740bfa63588cda15b024f2173ad..5c4fb1ac12f4c931b31884cb25b75aa367107a10 100644
--- a/chrome/browser/speech/speech_input_manager.cc
+++ b/chrome/browser/speech/speech_input_manager.cc
@@ -37,7 +37,9 @@ class SpeechInputManagerImpl : public SpeechInputManager,
const string16& value);
virtual void DidCompleteRecording(int caller_id);
virtual void DidCompleteRecognition(int caller_id);
- virtual void OnRecognizerError(int caller_id);
+ virtual void OnRecognizerError(int caller_id,
+ SpeechRecognizer::ErrorCode error);
+ virtual void DidCompleteEnvironmentEstimation(int caller_id);
// SpeechInputBubbleController::Delegate methods.
virtual void RecognitionCancelled(int caller_id);
@@ -49,6 +51,7 @@ class SpeechInputManagerImpl : public SpeechInputManager,
scoped_refptr<SpeechRecognizer> recognizer;
int render_process_id;
int render_view_id;
+ gfx::Rect element_rect;
};
// Private constructor to enforce singleton.
@@ -124,15 +127,13 @@ void SpeechInputManagerImpl::StartRecognition(
return;
}
- bubble_controller_->CreateBubble(caller_id, render_process_id,
- render_view_id, element_rect);
-
recording_caller_id_ = caller_id;
SpeechInputRequest request;
request.delegate = delegate;
request.recognizer = new SpeechRecognizer(this, caller_id);
request.render_process_id = render_process_id;
request.render_view_id = render_view_id;
+ request.element_rect = element_rect;
requests_[caller_id] = request;
request.recognizer->StartRecording();
}
@@ -173,12 +174,27 @@ void SpeechInputManagerImpl::DidCompleteRecognition(int caller_id) {
bubble_controller_->CloseBubble(caller_id);
}
-void SpeechInputManagerImpl::OnRecognizerError(int caller_id) {
+void SpeechInputManagerImpl::OnRecognizerError(
+ int caller_id, SpeechRecognizer::ErrorCode error) {
+ // TODO(satish): Show specific messages for the various error codes and allow
+ // user to retry without ending the recognition session if possible.
const SpeechInputRequest& request = requests_.find(caller_id)->second;
ShowErrorMessage(request.render_process_id, request.render_view_id,
l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_ERROR));
}
+void SpeechInputManagerImpl::DidCompleteEnvironmentEstimation(int caller_id) {
+ DCHECK(HasPendingRequest(caller_id));
+ DCHECK(recording_caller_id_ == caller_id);
+
+ // Speech recognizer has gathered enough background audio so we can ask the
+ // user to start speaking.
+ const SpeechInputRequest& request = requests_.find(caller_id)->second;
joth 2010/09/09 10:51:37 maybe easier as const SpeechInputRequest& request
+ bubble_controller_->CreateBubble(caller_id, request.render_process_id,
+ request.render_view_id,
+ request.element_rect);
+}
+
void SpeechInputManagerImpl::CancelRecognitionAndInformDelegate(int caller_id) {
SpeechInputManagerDelegate* cur_delegate = GetDelegate(caller_id);
CancelRecognition(caller_id);

Powered by Google App Engine
This is Rietveld 408576698