Chromium Code Reviews| Index: chrome/browser/speech/speech_recognizer.cc |
| diff --git a/chrome/browser/speech/speech_recognizer.cc b/chrome/browser/speech/speech_recognizer.cc |
| index 277393ca08f7e601f9d6832f33324cdef7606978..dbd5c15cd14d5259b66935e552be4b7587ed24cc 100644 |
| --- a/chrome/browser/speech/speech_recognizer.cc |
| +++ b/chrome/browser/speech/speech_recognizer.cc |
| @@ -141,7 +141,7 @@ SpeechRecognizer::~SpeechRecognizer() { |
| bool SpeechRecognizer::StartRecording() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| DCHECK(!audio_controller_.get()); |
| - DCHECK(!request_.get() || !request_->HasPendingRequest()); |
| + DCHECK(!request_.get()); // || !request_->HasPendingRequest()); |
| // The endpointer needs to estimate the environment/background noise before |
| // starting to treat the audio as user input. In |HandleOnData| we wait until |
| @@ -159,6 +159,10 @@ bool SpeechRecognizer::StartRecording() { |
| num_samples_recorded_ = 0; |
| audio_controller_->Record(); |
| + request_.reset(new SpeechRecognitionRequest( |
| + Profile::GetDefaultRequestContext(), this)); |
| + request_->Start(language_, grammar_, hardware_info_, kContentTypeSpeex); |
| + |
| return true; |
| } |
| @@ -191,7 +195,9 @@ void SpeechRecognizer::StopRecording() { |
| audio_controller_ = NULL; // Releases the ref ptr. |
| delegate_->DidCompleteRecording(caller_id_); |
| - |
| + DCHECK(request_.get()); |
| + request_->FinishAudioUpload(); |
| +/* |
|
vandebo (ex-Chrome)
2011/01/14 05:53:44
Should you delete this now dead code?
Satish
2011/01/14 18:09:29
The changes in this file are just a sample showing
|
| // If we haven't got any audio yet end the recognition sequence here. |
| if (audio_buffers_.empty()) { |
| // Guard against the delegate freeing us until we finish our job. |
| @@ -215,11 +221,8 @@ void SpeechRecognizer::StopRecording() { |
| data.append(*(*it)); |
| } |
| - DCHECK(!request_.get()); |
| - request_.reset(new SpeechRecognitionRequest( |
| - Profile::GetDefaultRequestContext(), this)); |
| - request_->Send(language_, grammar_, hardware_info_, kContentTypeSpeex, data); |
| ReleaseAudioBuffers(); // No need to keep the audio anymore. |
| +*/ |
| } |
| void SpeechRecognizer::ReleaseAudioBuffers() { |
| @@ -281,6 +284,12 @@ void SpeechRecognizer::HandleOnData(string* data) { |
| delete data; |
| num_samples_recorded_ += num_samples; |
| + DCHECK(request_.get()); |
| + for (AudioBufferQueue::iterator it = audio_buffers_.begin(); |
| + it != audio_buffers_.end(); it++) |
| + request_->UploadAudioChunk(**it); |
| + ReleaseAudioBuffers(); |
| + |
| if (endpointer_.IsEstimatingEnvironment()) { |
| // Check if we have gathered enough audio for the endpointer to do |
| // environment estimation and should move on to detect speech/end of speech. |