OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/speech/speech_recognition_request.h" | 5 #include "chrome/browser/speech/speech_recognition_request.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_util.h" | 10 #include "base/string_util.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 const DictionaryValue* hypothesis_value = | 84 const DictionaryValue* hypothesis_value = |
85 static_cast<DictionaryValue*>(hypothesis); | 85 static_cast<DictionaryValue*>(hypothesis); |
86 string16 utterance; | 86 string16 utterance; |
87 if (!hypothesis_value->GetString(kUtteranceString, &utterance)) { | 87 if (!hypothesis_value->GetString(kUtteranceString, &utterance)) { |
88 LOG(WARNING) << "ParseServerResponse: Missing utterance value."; | 88 LOG(WARNING) << "ParseServerResponse: Missing utterance value."; |
89 break; | 89 break; |
90 } | 90 } |
91 | 91 |
92 // It is not an error if the 'confidence' field is missing. | 92 // It is not an error if the 'confidence' field is missing. |
93 double confidence = 0.0; | 93 double confidence = 0.0; |
94 hypothesis_value->GetReal(kConfidenceString, &confidence); | 94 hypothesis_value->GetDouble(kConfidenceString, &confidence); |
95 | 95 |
96 result->push_back(speech_input::SpeechInputResultItem(utterance, | 96 result->push_back(speech_input::SpeechInputResultItem(utterance, |
97 confidence)); | 97 confidence)); |
98 } | 98 } |
99 | 99 |
100 if (index < hypotheses_list->GetSize()) { | 100 if (index < hypotheses_list->GetSize()) { |
101 result->clear(); | 101 result->clear(); |
102 return false; | 102 return false; |
103 } | 103 } |
104 | 104 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 SpeechInputResultArray result; | 188 SpeechInputResultArray result; |
189 if (!error) | 189 if (!error) |
190 error = !ParseServerResponse(data, &result); | 190 error = !ParseServerResponse(data, &result); |
191 url_fetcher_.reset(); | 191 url_fetcher_.reset(); |
192 | 192 |
193 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; | 193 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; |
194 delegate_->SetRecognitionResult(error, result); | 194 delegate_->SetRecognitionResult(error, result); |
195 } | 195 } |
196 | 196 |
197 } // namespace speech_input | 197 } // namespace speech_input |
OLD | NEW |