diff --git a/android/jni/jni/com_google_espeakengine.cpp b/android/jni/jni/com_google_espeakengine.cpp index 2706b803..273e6613 100644 --- a/android/jni/jni/com_google_espeakengine.cpp +++ b/android/jni/jni/com_google_espeakengine.cpp @@ -480,6 +480,11 @@ tts_result TtsEngine::setProperty(const char *property, const char *value, const result = espeak_SetParameter(espeakRATE, rate, 0); } else if (strncmp(property, "pitch", 5) == 0) { int pitch = atoi(value); + // The values of pitch from android range from 50 - 200, with 100 being normal. + // The values espeak supports are from 0 - 100, with 50 being normal. + // Therefore, halve the value to get the value that espeak supports: + pitch = pitch / 2; + if (DEBUG) LOGV("setProperty pitch : pitch=%d", pitch); result = espeak_SetParameter(espeakPITCH, pitch, 0); } else if (strncmp(property, "volume", 6) == 0) { int volume = atoi(value); @@ -535,7 +540,7 @@ tts_result TtsEngine::getProperty(const char *property, char *value, size_t *ios return TTS_SUCCESS; } else if (strncmp(property, "pitch", 5) == 0) { char tmppitch[4]; - sprintf(tmppitch, "%d", espeak_GetParameter(espeakPITCH, 1)); + sprintf(tmppitch, "%d", (espeak_GetParameter(espeakPITCH, 1) * 2)); if (*iosize < strlen(tmppitch)+1) { *iosize = strlen(tmppitch) + 1; return TTS_PROPERTY_SIZE_TOO_SMALL; diff --git a/android/jni/jni/com_googlecode_eyesfree_espeak_eSpeakService.cpp b/android/jni/jni/com_googlecode_eyesfree_espeak_eSpeakService.cpp index f88a278a..6e190c4f 100644 --- a/android/jni/jni/com_googlecode_eyesfree_espeak_eSpeakService.cpp +++ b/android/jni/jni/com_googlecode_eyesfree_espeak_eSpeakService.cpp @@ -288,7 +288,11 @@ JNICALL Java_com_googlecode_eyesfree_espeak_SpeechSynthesis_nativeSetRate( JNIEXPORT jboolean JNICALL Java_com_googlecode_eyesfree_espeak_SpeechSynthesis_nativeSetPitch( JNIEnv *env, jobject object, jint pitch) { - if (DEBUG) LOGV("%s", __FUNCTION__); + // The values of pitch from android range from 50 - 200, with 100 being normal. + // The values espeak supports are from 0 - 100, with 50 being normal. + // Therefore, halve the value to get the value that espeak supports: + pitch = pitch / 2; + if (DEBUG) LOGV("%s(pitch=%d)", __FUNCTION__, pitch); const espeak_ERROR result = espeak_SetParameter(espeakPITCH, (int) pitch, 0); switch (result) {