| 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) + | 208 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&')); |
| 209 base::JoinString(parts, "&")); | |
| 210 | 209 |
| 211 encoder_.reset(AudioEncoder::Create(kDefaultAudioCodec, | 210 encoder_.reset(AudioEncoder::Create(kDefaultAudioCodec, |
| 212 config_.audio_sample_rate, | 211 config_.audio_sample_rate, |
| 213 config_.audio_num_bits_per_sample)); | 212 config_.audio_num_bits_per_sample)); |
| 214 DCHECK(encoder_.get()); | 213 DCHECK(encoder_.get()); |
| 215 url_fetcher_ = net::URLFetcher::Create(url_fetcher_id_for_tests, url, | 214 url_fetcher_ = net::URLFetcher::Create(url_fetcher_id_for_tests, url, |
| 216 net::URLFetcher::POST, this); | 215 net::URLFetcher::POST, this); |
| 217 url_fetcher_->SetChunkedUpload(encoder_->mime_type()); | 216 url_fetcher_->SetChunkedUpload(encoder_->mime_type()); |
| 218 url_fetcher_->SetRequestContext(url_context_.get()); | 217 url_fetcher_->SetRequestContext(url_context_.get()); |
| 219 url_fetcher_->SetReferrer(config_.origin_url); | 218 url_fetcher_->SetReferrer(config_.origin_url); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 287 |
| 289 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { | 288 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { |
| 290 return url_fetcher_ != NULL; | 289 return url_fetcher_ != NULL; |
| 291 } | 290 } |
| 292 | 291 |
| 293 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { | 292 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { |
| 294 return kAudioPacketIntervalMs; | 293 return kAudioPacketIntervalMs; |
| 295 } | 294 } |
| 296 | 295 |
| 297 } // namespace content | 296 } // namespace content |
| OLD | NEW |