OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/speech_recognizer_impl_android.h" | 5 #include "content/browser/speech/speech_recognizer_impl_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 139 } |
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
141 if (state_ == STATE_CAPTURING_AUDIO) | 141 if (state_ == STATE_CAPTURING_AUDIO) |
142 state_ = STATE_AWAITING_FINAL_RESULT; | 142 state_ = STATE_AWAITING_FINAL_RESULT; |
143 listener()->OnAudioEnd(session_id()); | 143 listener()->OnAudioEnd(session_id()); |
144 } | 144 } |
145 | 145 |
146 void SpeechRecognizerImplAndroid::OnRecognitionResults(JNIEnv* env, jobject obj, | 146 void SpeechRecognizerImplAndroid::OnRecognitionResults(JNIEnv* env, jobject obj, |
147 jobjectArray strings, jfloatArray floats, jboolean provisional) { | 147 jobjectArray strings, jfloatArray floats, jboolean provisional) { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
149 std::vector<string16> options; | 149 std::vector<base::string16> options; |
150 AppendJavaStringArrayToStringVector(env, strings, &options); | 150 AppendJavaStringArrayToStringVector(env, strings, &options); |
151 std::vector<float> scores(options.size(), 0.0); | 151 std::vector<float> scores(options.size(), 0.0); |
152 if (floats != NULL) | 152 if (floats != NULL) |
153 JavaFloatArrayToFloatVector(env, floats, &scores); | 153 JavaFloatArrayToFloatVector(env, floats, &scores); |
154 SpeechRecognitionResults results; | 154 SpeechRecognitionResults results; |
155 results.push_back(SpeechRecognitionResult()); | 155 results.push_back(SpeechRecognitionResult()); |
156 SpeechRecognitionResult& result = results.back(); | 156 SpeechRecognitionResult& result = results.back(); |
157 CHECK_EQ(options.size(), scores.size()); | 157 CHECK_EQ(options.size(), scores.size()); |
158 for (size_t i = 0; i < options.size(); ++i) { | 158 for (size_t i = 0; i < options.size(); ++i) { |
159 result.hypotheses.push_back(SpeechRecognitionHypothesis( | 159 result.hypotheses.push_back(SpeechRecognitionHypothesis( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 state_ = STATE_IDLE; | 197 state_ = STATE_IDLE; |
198 listener()->OnRecognitionEnd(session_id()); | 198 listener()->OnRecognitionEnd(session_id()); |
199 } | 199 } |
200 | 200 |
201 // static | 201 // static |
202 bool SpeechRecognizerImplAndroid::RegisterSpeechRecognizer(JNIEnv* env) { | 202 bool SpeechRecognizerImplAndroid::RegisterSpeechRecognizer(JNIEnv* env) { |
203 return RegisterNativesImpl(env); | 203 return RegisterNativesImpl(env); |
204 } | 204 } |
205 | 205 |
206 } // namespace content | 206 } // namespace content |
OLD | NEW |