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

Side by Side Diff: content/browser/speech/speech_recognizer.cc

Issue 8199010: Fixing misleading name a in speech input setting and related variables. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/browser/browser_thread.h" 8 #include "content/browser/browser_thread.h"
9 #include "net/url_request/url_request_context_getter.h" 9 #include "net/url_request/url_request_context_getter.h"
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const ChannelLayout SpeechRecognizer::kChannelLayout = CHANNEL_LAYOUT_MONO; 51 const ChannelLayout SpeechRecognizer::kChannelLayout = CHANNEL_LAYOUT_MONO;
52 const int SpeechRecognizer::kNumBitsPerAudioSample = 16; 52 const int SpeechRecognizer::kNumBitsPerAudioSample = 16;
53 const int SpeechRecognizer::kNoSpeechTimeoutSec = 8; 53 const int SpeechRecognizer::kNoSpeechTimeoutSec = 8;
54 const int SpeechRecognizer::kEndpointerEstimationTimeMs = 300; 54 const int SpeechRecognizer::kEndpointerEstimationTimeMs = 300;
55 55
56 SpeechRecognizer::SpeechRecognizer(Delegate* delegate, 56 SpeechRecognizer::SpeechRecognizer(Delegate* delegate,
57 int caller_id, 57 int caller_id,
58 const std::string& language, 58 const std::string& language,
59 const std::string& grammar, 59 const std::string& grammar,
60 net::URLRequestContextGetter* context_getter, 60 net::URLRequestContextGetter* context_getter,
61 bool censor_results, 61 bool filter_profanities,
62 const std::string& hardware_info, 62 const std::string& hardware_info,
63 const std::string& origin_url) 63 const std::string& origin_url)
64 : delegate_(delegate), 64 : delegate_(delegate),
65 caller_id_(caller_id), 65 caller_id_(caller_id),
66 language_(language), 66 language_(language),
67 grammar_(grammar), 67 grammar_(grammar),
68 censor_results_(censor_results), 68 filter_profanities_(filter_profanities),
69 hardware_info_(hardware_info), 69 hardware_info_(hardware_info),
70 origin_url_(origin_url), 70 origin_url_(origin_url),
71 context_getter_(context_getter), 71 context_getter_(context_getter),
72 codec_(AudioEncoder::CODEC_FLAC), 72 codec_(AudioEncoder::CODEC_FLAC),
73 encoder_(NULL), 73 encoder_(NULL),
74 endpointer_(kAudioSampleRate), 74 endpointer_(kAudioSampleRate),
75 num_samples_recorded_(0), 75 num_samples_recorded_(0),
76 audio_level_(0.0f) { 76 audio_level_(0.0f) {
77 endpointer_.set_speech_input_complete_silence_length( 77 endpointer_.set_speech_input_complete_silence_length(
78 base::Time::kMicrosecondsPerSecond / 2); 78 base::Time::kMicrosecondsPerSecond / 2);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 endpointer_.ProcessAudio(samples, num_samples, &rms); 218 endpointer_.ProcessAudio(samples, num_samples, &rms);
219 bool did_clip = Clipping(samples, num_samples); 219 bool did_clip = Clipping(samples, num_samples);
220 delete data; 220 delete data;
221 num_samples_recorded_ += num_samples; 221 num_samples_recorded_ += num_samples;
222 222
223 if (request_ == NULL) { 223 if (request_ == NULL) {
224 // 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
225 // server to send the data and inform the delegate. 225 // server to send the data and inform the delegate.
226 delegate_->DidStartReceivingAudio(caller_id_); 226 delegate_->DidStartReceivingAudio(caller_id_);
227 request_.reset(new SpeechRecognitionRequest(context_getter_.get(), this)); 227 request_.reset(new SpeechRecognitionRequest(context_getter_.get(), this));
228 request_->Start(language_, grammar_, censor_results_, 228 request_->Start(language_, grammar_, filter_profanities_,
229 hardware_info_, origin_url_, encoder_->mime_type()); 229 hardware_info_, origin_url_, encoder_->mime_type());
230 } 230 }
231 231
232 string encoded_data; 232 string encoded_data;
233 encoder_->GetEncodedDataAndClear(&encoded_data); 233 encoder_->GetEncodedDataAndClear(&encoded_data);
234 DCHECK(!encoded_data.empty()); 234 DCHECK(!encoded_data.empty());
235 request_->UploadAudioChunk(encoded_data, false /* is_last_chunk */); 235 request_->UploadAudioChunk(encoded_data, false /* is_last_chunk */);
236 236
237 if (endpointer_.IsEstimatingEnvironment()) { 237 if (endpointer_.IsEstimatingEnvironment()) {
238 // Check if we have gathered enough audio for the endpointer to do 238 // Check if we have gathered enough audio for the endpointer to do
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) { 297 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) {
298 CancelRecognition(); 298 CancelRecognition();
299 299
300 // Guard against the delegate freeing us until we finish our job. 300 // Guard against the delegate freeing us until we finish our job.
301 scoped_refptr<SpeechRecognizer> me(this); 301 scoped_refptr<SpeechRecognizer> me(this);
302 delegate_->OnRecognizerError(caller_id_, error); 302 delegate_->OnRecognizerError(caller_id_, error);
303 } 303 }
304 304
305 } // namespace speech_input 305 } // namespace speech_input
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698