OLD | NEW |
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 #include "content/browser/speech/speech_recognizer.h" | 5 #include "content/browser/speech/speech_recognizer.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
10 #include "net/url_request/url_request_context_getter.h" | 10 #include "net/url_request/url_request_context_getter.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 endpointer_.ProcessAudio(samples, num_samples, &rms); | 215 endpointer_.ProcessAudio(samples, num_samples, &rms); |
216 bool did_clip = Clipping(samples, num_samples); | 216 bool did_clip = Clipping(samples, num_samples); |
217 delete data; | 217 delete data; |
218 num_samples_recorded_ += num_samples; | 218 num_samples_recorded_ += num_samples; |
219 | 219 |
220 if (request_ == NULL) { | 220 if (request_ == NULL) { |
221 // This was the first audio packet recorded, so start a request to the | 221 // This was the first audio packet recorded, so start a request to the |
222 // server to send the data and inform the delegate. | 222 // server to send the data and inform the delegate. |
223 delegate_->DidStartReceivingAudio(caller_id_); | 223 delegate_->DidStartReceivingAudio(caller_id_); |
224 request_.reset(new SpeechRecognitionRequest( | 224 request_.reset(new SpeechRecognitionRequest( |
225 Profile::GetDefaultRequestContext(), this)); | 225 Profile::Deprecated::GetDefaultRequestContext(), this)); |
226 request_->Start(language_, grammar_, hardware_info_, origin_url_, | 226 request_->Start(language_, grammar_, hardware_info_, origin_url_, |
227 encoder_->mime_type()); | 227 encoder_->mime_type()); |
228 } | 228 } |
229 | 229 |
230 string encoded_data; | 230 string encoded_data; |
231 encoder_->GetEncodedDataAndClear(&encoded_data); | 231 encoder_->GetEncodedDataAndClear(&encoded_data); |
232 DCHECK(!encoded_data.empty()); | 232 DCHECK(!encoded_data.empty()); |
233 request_->UploadAudioChunk(encoded_data, false /* is_last_chunk */); | 233 request_->UploadAudioChunk(encoded_data, false /* is_last_chunk */); |
234 | 234 |
235 if (endpointer_.IsEstimatingEnvironment()) { | 235 if (endpointer_.IsEstimatingEnvironment()) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 294 |
295 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) { | 295 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) { |
296 CancelRecognition(); | 296 CancelRecognition(); |
297 | 297 |
298 // Guard against the delegate freeing us until we finish our job. | 298 // Guard against the delegate freeing us until we finish our job. |
299 scoped_refptr<SpeechRecognizer> me(this); | 299 scoped_refptr<SpeechRecognizer> me(this); |
300 delegate_->OnRecognizerError(caller_id_, error); | 300 delegate_->OnRecognizerError(caller_id_, error); |
301 } | 301 } |
302 | 302 |
303 } // namespace speech_input | 303 } // namespace speech_input |
OLD | NEW |