diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:31 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:31 -0800 |
commit | c9dbe4c878cb0bfabd4255b25183a22de02bbfc1 (patch) | |
tree | f2f3008ab6b78f4550a56893ad9f96e91c75f0fd | |
parent | 848d1df23e9a0c0d98cb45905355eee05ce3fa34 (diff) | |
download | srec-c9dbe4c878cb0bfabd4255b25183a22de02bbfc1.tar.gz |
auto import from //depot/cupcake/@137055
-rw-r--r-- | srec_jni/android_speech_srec_MicrophoneInputStream.cpp | 5 | ||||
-rw-r--r-- | srec_jni/android_speech_srec_Recognizer.cpp | 28 |
2 files changed, 26 insertions, 7 deletions
diff --git a/srec_jni/android_speech_srec_MicrophoneInputStream.cpp b/srec_jni/android_speech_srec_MicrophoneInputStream.cpp index 6b0ac19..8ca4cdd 100644 --- a/srec_jni/android_speech_srec_MicrophoneInputStream.cpp +++ b/srec_jni/android_speech_srec_MicrophoneInputStream.cpp @@ -69,19 +69,16 @@ static JNIEXPORT jint JNICALL Java_android_speech_srec_Recognizer_AudioRecordNew LOGE("initCheck error %d ", s); } } - LOGV("new AudioRecord(%p)", ar); return (int)ar; } static JNIEXPORT int JNICALL Java_android_speech_srec_Recognizer_AudioRecordStart (JNIEnv *env, jclass clazz, jint audioRecord) { - LOGV("start = 0x%x", audioRecord); return (int)(((AudioRecord*)audioRecord)->start()); } static JNIEXPORT jint JNICALL Java_android_speech_srec_Recognizer_AudioRecordRead (JNIEnv *env, jclass clazz, jint audioRecord, jbyteArray array, jint offset, jint length) { - LOGV("read(0x%x)", audioRecord); jbyte buffer[4096]; if (length > (int)sizeof(buffer)) length = sizeof(buffer); length = ((AudioRecord*)audioRecord)->read(buffer, length); @@ -95,7 +92,6 @@ static JNIEXPORT jint JNICALL Java_android_speech_srec_Recognizer_AudioRecordRea static JNIEXPORT void JNICALL Java_android_speech_srec_Recognizer_AudioRecordStop (JNIEnv *env, jclass clazz, jint audioRecord) { - LOGV("stop(0x%x)", audioRecord); if (int rtn = ((AudioRecord*)audioRecord)->stop()) { throwException(env, "java/io/IOException", "AudioRecord::stop failed %d", rtn); } @@ -103,7 +99,6 @@ static JNIEXPORT void JNICALL Java_android_speech_srec_Recognizer_AudioRecordSto static JNIEXPORT void JNICALL Java_android_speech_srec_Recognizer_AudioRecordDelete (JNIEnv *env, jclass clazz, jint audioRecord) { - LOGV("delete(0x%x)", audioRecord); delete (AudioRecord*)audioRecord; } diff --git a/srec_jni/android_speech_srec_Recognizer.cpp b/srec_jni/android_speech_srec_Recognizer.cpp index c71159b..abaf883 100644 --- a/srec_jni/android_speech_srec_Recognizer.cpp +++ b/srec_jni/android_speech_srec_Recognizer.cpp @@ -493,8 +493,32 @@ static JNIEXPORT jint JNICALL Java_android_speech_srec_Recognizer_SR_1Recognizer static JNIEXPORT jobjectArray JNICALL Java_android_speech_srec_Recognizer_SR_1RecognizerResultGetKeyList (JNIEnv *env, jclass clazz, jint recognizer, jint nbest) { - unimplemented(env); - return NULL; + // fetch list + LCHAR* list[200]; + size_t listSize = sizeof(list) / sizeof(list[0]); + ESR_ReturnCode esr_status = SR_RecognizerResultGetKeyList(((SR_RecognizerImpl*)recognizer)->result, nbest, list, &listSize); + if (esr_status) { + checkEsrError(env, esr_status); + return NULL; + } + + // create String[] of keys + jclass stringClass = env->FindClass("[Ljava/lang/String;"); + if (!stringClass) return NULL; + jobjectArray array = env->NewObjectArray(listSize, stringClass, NULL); + if (!array) return NULL; + + // fill it + for (size_t i = 0; i < listSize; i++) { + // generate new String for key + jstring key = env->NewStringUTF(list[i]); + if (!key) return NULL; + // set the array + env->SetObjectArrayElement(array, i, key); + env->DeleteLocalRef(key); + } + + return array; } static JNIEXPORT jstring JNICALL Java_android_speech_srec_Recognizer_SR_1RecognizerResultGetValue |