summaryrefslogtreecommitdiffstats
path: root/content/browser/speech/google_streaming_remote_engine.cc
diff options
context:
space:
mode:
authorhans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-04 15:32:03 +0000
committerhans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-04 15:32:03 +0000
commita2f4727253ae20be6a9c54bc7c04235731c74d5b (patch)
tree82d639acbe32b2372582920be363dd429068d78b /content/browser/speech/google_streaming_remote_engine.cc
parentbbf18fc3918bc97ed3c839884cada1b49c6d8fc5 (diff)
downloadchromium_src-a2f4727253ae20be6a9c54bc7c04235731c74d5b.zip
chromium_src-a2f4727253ae20be6a9c54bc7c04235731c74d5b.tar.gz
chromium_src-a2f4727253ae20be6a9c54bc7c04235731c74d5b.tar.bz2
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
Diffstat (limited to 'content/browser/speech/google_streaming_remote_engine.cc')
-rw-r--r--content/browser/speech/google_streaming_remote_engine.cc7
1 files changed, 6 insertions, 1 deletions
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()) {