OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/google_one_shot_remote_engine.h" | 5 #include "content/browser/speech/google_one_shot_remote_engine.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 198 |
199 if (!config_.hardware_info.empty()) | 199 if (!config_.hardware_info.empty()) |
200 parts.push_back("xhw=" + net::EscapeQueryParamValue(config_.hardware_info, | 200 parts.push_back("xhw=" + net::EscapeQueryParamValue(config_.hardware_info, |
201 true)); | 201 true)); |
202 parts.push_back("maxresults=" + base::UintToString(config_.max_hypotheses)); | 202 parts.push_back("maxresults=" + base::UintToString(config_.max_hypotheses)); |
203 parts.push_back(config_.filter_profanities ? "pfilter=2" : "pfilter=0"); | 203 parts.push_back(config_.filter_profanities ? "pfilter=2" : "pfilter=0"); |
204 | 204 |
205 std::string api_key = google_apis::GetAPIKey(); | 205 std::string api_key = google_apis::GetAPIKey(); |
206 parts.push_back("key=" + net::EscapeQueryParamValue(api_key, true)); | 206 parts.push_back("key=" + net::EscapeQueryParamValue(api_key, true)); |
207 | 207 |
208 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&')); | 208 GURL url(std::string(kDefaultSpeechRecognitionUrl) + |
| 209 base::JoinString(parts, "&")); |
209 | 210 |
210 encoder_.reset(AudioEncoder::Create(kDefaultAudioCodec, | 211 encoder_.reset(AudioEncoder::Create(kDefaultAudioCodec, |
211 config_.audio_sample_rate, | 212 config_.audio_sample_rate, |
212 config_.audio_num_bits_per_sample)); | 213 config_.audio_num_bits_per_sample)); |
213 DCHECK(encoder_.get()); | 214 DCHECK(encoder_.get()); |
214 url_fetcher_ = net::URLFetcher::Create(url_fetcher_id_for_tests, url, | 215 url_fetcher_ = net::URLFetcher::Create(url_fetcher_id_for_tests, url, |
215 net::URLFetcher::POST, this); | 216 net::URLFetcher::POST, this); |
216 url_fetcher_->SetChunkedUpload(encoder_->mime_type()); | 217 url_fetcher_->SetChunkedUpload(encoder_->mime_type()); |
217 url_fetcher_->SetRequestContext(url_context_.get()); | 218 url_fetcher_->SetRequestContext(url_context_.get()); |
218 url_fetcher_->SetReferrer(config_.origin_url); | 219 url_fetcher_->SetReferrer(config_.origin_url); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 288 |
288 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { | 289 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { |
289 return url_fetcher_ != NULL; | 290 return url_fetcher_ != NULL; |
290 } | 291 } |
291 | 292 |
292 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { | 293 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { |
293 return kAudioPacketIntervalMs; | 294 return kAudioPacketIntervalMs; |
294 } | 295 } |
295 | 296 |
296 } // namespace content | 297 } // namespace content |
OLD | NEW |