From a2f4727253ae20be6a9c54bc7c04235731c74d5b Mon Sep 17 00:00:00 2001 From: "hans@chromium.org" Date: Thu, 4 Oct 2012 15:32:03 +0000 Subject: Speech JavaScript API: Limit the 'maxAlternatives' server param to 30. BUG=116954 Review URL: https://chromiumcodereview.appspot.com/11065009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160138 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/speech/google_streaming_remote_engine.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'content/browser/speech/google_streaming_remote_engine.cc') diff --git a/content/browser/speech/google_streaming_remote_engine.cc b/content/browser/speech/google_streaming_remote_engine.cc index 81e6cb9..0b71a19 100644 --- a/content/browser/speech/google_streaming_remote_engine.cc +++ b/content/browser/speech/google_streaming_remote_engine.cc @@ -44,6 +44,9 @@ const int kAudioPacketIntervalMs = 100; const speech::AudioEncoder::Codec kDefaultAudioCodec = speech::AudioEncoder::CODEC_FLAC; +// This mathces the maximum maxAlternatives value supported by the server. +const uint32 kMaxMaxAlternatives = 30; + // TODO(hans): Remove this and other logging when we don't need it anymore. void DumpResponse(const std::string& response) { DVLOG(1) << "------------"; @@ -350,8 +353,10 @@ GoogleStreamingRemoteEngine::ConnectBothStreams(const FSMEventArgs&) { upstream_args.push_back( config_.filter_profanities ? "pFilter=2" : "pFilter=0"); if (config_.max_hypotheses > 0U) { + int max_alternatives = std::min(kMaxMaxAlternatives, + config_.max_hypotheses); upstream_args.push_back("maxAlternatives=" + - base::UintToString(config_.max_hypotheses)); + base::UintToString(max_alternatives)); } upstream_args.push_back("client=chromium"); if (!config_.hardware_info.empty()) { -- cgit v1.1