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" | |
9 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
| 9 #include "content/browser/content_browser_client.h" |
| 10 #include "content/common/content_client.h" |
10 #include "net/url_request/url_request_context_getter.h" | 11 #include "net/url_request/url_request_context_getter.h" |
11 | 12 |
12 using media::AudioInputController; | 13 using media::AudioInputController; |
13 using std::string; | 14 using std::string; |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // The following constants are related to the volume level indicator shown in | 18 // The following constants are related to the volume level indicator shown in |
18 // the UI for recorded audio. | 19 // the UI for recorded audio. |
19 // Multiplier used when new volume is greater than previous level. | 20 // Multiplier used when new volume is greater than previous level. |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 float rms; | 217 float rms; |
217 endpointer_.ProcessAudio(samples, num_samples, &rms); | 218 endpointer_.ProcessAudio(samples, num_samples, &rms); |
218 bool did_clip = Clipping(samples, num_samples); | 219 bool did_clip = Clipping(samples, num_samples); |
219 delete data; | 220 delete data; |
220 num_samples_recorded_ += num_samples; | 221 num_samples_recorded_ += num_samples; |
221 | 222 |
222 if (request_ == NULL) { | 223 if (request_ == NULL) { |
223 // This was the first audio packet recorded, so start a request to the | 224 // This was the first audio packet recorded, so start a request to the |
224 // server to send the data and inform the delegate. | 225 // server to send the data and inform the delegate. |
225 delegate_->DidStartReceivingAudio(caller_id_); | 226 delegate_->DidStartReceivingAudio(caller_id_); |
226 request_.reset(new SpeechRecognitionRequest( | 227 // Deprecated; see http://crbug.com/92366 |
227 Profile::Deprecated::GetDefaultRequestContext(), this)); | 228 net::URLRequestContextGetter* context_getter = |
| 229 content::GetContentClient()->browser()-> |
| 230 GetDefaultRequestContextDeprecatedCrBug64339(); |
| 231 request_.reset(new SpeechRecognitionRequest(context_getter, this)); |
228 request_->Start(language_, grammar_, censor_results_, hardware_info_, | 232 request_->Start(language_, grammar_, censor_results_, hardware_info_, |
229 origin_url_, encoder_->mime_type()); | 233 origin_url_, encoder_->mime_type()); |
230 } | 234 } |
231 | 235 |
232 string encoded_data; | 236 string encoded_data; |
233 encoder_->GetEncodedDataAndClear(&encoded_data); | 237 encoder_->GetEncodedDataAndClear(&encoded_data); |
234 DCHECK(!encoded_data.empty()); | 238 DCHECK(!encoded_data.empty()); |
235 request_->UploadAudioChunk(encoded_data, false /* is_last_chunk */); | 239 request_->UploadAudioChunk(encoded_data, false /* is_last_chunk */); |
236 | 240 |
237 if (endpointer_.IsEstimatingEnvironment()) { | 241 if (endpointer_.IsEstimatingEnvironment()) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 300 |
297 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) { | 301 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) { |
298 CancelRecognition(); | 302 CancelRecognition(); |
299 | 303 |
300 // Guard against the delegate freeing us until we finish our job. | 304 // Guard against the delegate freeing us until we finish our job. |
301 scoped_refptr<SpeechRecognizer> me(this); | 305 scoped_refptr<SpeechRecognizer> me(this); |
302 delegate_->OnRecognizerError(caller_id_, error); | 306 delegate_->OnRecognizerError(caller_id_, error); |
303 } | 307 } |
304 | 308 |
305 } // namespace speech_input | 309 } // namespace speech_input |
OLD | NEW |