From 00b70cbb307fb22587032b31caea4704f4e9850d Mon Sep 17 00:00:00 2001 From: Rynhardt P Kruger Date: Fri, 24 Dec 2010 01:43:37 +0200 Subject: [PATCH] Fixed bug in espeak driver where garbage was spoken at the end of strings. Also tracked the Espeak Test class. --- src/c/EspeakSpeechEngine.c | 4 ++-- tests/Test.java | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/Test.java diff --git a/src/c/EspeakSpeechEngine.c b/src/c/EspeakSpeechEngine.c index 90ab883..00390aa 100644 --- a/src/c/EspeakSpeechEngine.c +++ b/src/c/EspeakSpeechEngine.c @@ -42,9 +42,9 @@ return JNI_TRUE; JNIEXPORT void JNICALL Java_org_alterverse_speech_EspeakSpeechEngine_speak (JNIEnv *env, jobject jobj, jstring jstr) { const char * str = env->GetStringUTFChars(jstr,0); -int size = env->GetStringLength(jstr); +int size = env->GetStringUTFLength(jstr); espeak_Cancel(); -espeak_Synth(str,sizeof(str),0,POS_CHARACTER,0,0,NULL,NULL); +espeak_Synth(str,size,0,POS_CHARACTER,0,0,NULL,NULL); env->ReleaseStringUTFChars(jstr,str); } diff --git a/tests/Test.java b/tests/Test.java new file mode 100644 index 0000000..6382a9e --- /dev/null +++ b/tests/Test.java @@ -0,0 +1,23 @@ +import org.alterverse.speech.*; + +public class Test { +public static void main(String [] args) { +EspeakSpeechEngine espeak = new EspeakSpeechEngine(); +espeak.speak("Hello, world!"); + try { +System.in.read(); +espeak.setRate(10); +espeak.speak("This is very slow."); +System.in.read(); +espeak.setRate(95); +espeak.speak("This is very fast."); +System.in.read(); +espeak.setRate(50); +espeak.setPitch(90); +espeak.speak("This is very high!"); +System.in.read(); +} catch(Exception x) { +} +espeak.destroy(); +} +} -- 2.11.4.GIT