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/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return false; | 103 return false; |
104 } | 104 } |
105 | 105 |
106 const ListValue* hypotheses_list = | 106 const ListValue* hypotheses_list = |
107 static_cast<const ListValue*>(hypotheses_value); | 107 static_cast<const ListValue*>(hypotheses_value); |
108 | 108 |
109 // For now we support only single shot recognition, so we are giving only a | 109 // For now we support only single shot recognition, so we are giving only a |
110 // final result, consisting of one fragment (with one or more hypotheses). | 110 // final result, consisting of one fragment (with one or more hypotheses). |
111 size_t index = 0; | 111 size_t index = 0; |
112 for (; index < hypotheses_list->GetSize(); ++index) { | 112 for (; index < hypotheses_list->GetSize(); ++index) { |
113 Value* hypothesis = NULL; | 113 const Value* hypothesis = NULL; |
114 if (!hypotheses_list->Get(index, &hypothesis)) { | 114 if (!hypotheses_list->Get(index, &hypothesis)) { |
115 LOG(WARNING) << "ParseServerResponse: Unable to read hypothesis value."; | 115 LOG(WARNING) << "ParseServerResponse: Unable to read hypothesis value."; |
116 break; | 116 break; |
117 } | 117 } |
118 DCHECK(hypothesis); | 118 DCHECK(hypothesis); |
119 if (!hypothesis->IsType(Value::TYPE_DICTIONARY)) { | 119 if (!hypothesis->IsType(Value::TYPE_DICTIONARY)) { |
120 LOG(WARNING) << "ParseServerResponse: Unexpected value type " | 120 LOG(WARNING) << "ParseServerResponse: Unexpected value type " |
121 << hypothesis->GetType(); | 121 << hypothesis->GetType(); |
122 break; | 122 break; |
123 } | 123 } |
124 | 124 |
125 const DictionaryValue* hypothesis_value = | 125 const DictionaryValue* hypothesis_value = |
126 static_cast<DictionaryValue*>(hypothesis); | 126 static_cast<const DictionaryValue*>(hypothesis); |
127 string16 utterance; | 127 string16 utterance; |
128 | 128 |
129 if (!hypothesis_value->GetString(kUtteranceString, &utterance)) { | 129 if (!hypothesis_value->GetString(kUtteranceString, &utterance)) { |
130 LOG(WARNING) << "ParseServerResponse: Missing utterance value."; | 130 LOG(WARNING) << "ParseServerResponse: Missing utterance value."; |
131 break; | 131 break; |
132 } | 132 } |
133 | 133 |
134 // It is not an error if the 'confidence' field is missing. | 134 // It is not an error if the 'confidence' field is missing. |
135 double confidence = 0.0; | 135 double confidence = 0.0; |
136 hypothesis_value->GetDouble(kConfidenceString, &confidence); | 136 hypothesis_value->GetDouble(kConfidenceString, &confidence); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { | 284 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { |
285 return url_fetcher_ != NULL; | 285 return url_fetcher_ != NULL; |
286 } | 286 } |
287 | 287 |
288 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { | 288 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { |
289 return kAudioPacketIntervalMs; | 289 return kAudioPacketIntervalMs; |
290 } | 290 } |
291 | 291 |
292 } // namespace speech | 292 } // namespace speech |
OLD | NEW |