| 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..60396b4a4724908b7455eed1516c435fd9cd2aee 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();
|
| +/*
|
| // 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,10 @@ void SpeechRecognizer::HandleOnData(string* data) {
|
| delete data;
|
| num_samples_recorded_ += num_samples;
|
|
|
| + DCHECK(request_.get());
|
| + request_->UploadAudioChunk(**audio_buffers_.begin());
|
| + 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.
|
|
|