Browse Source

espeak specifies rate in WPM but android specifies it as a percentage, therefore correctly scale against the default espeak WPM

master
Reece H. Dunn 12 years ago
parent
commit
7afbbf57d5

+ 3
- 6
jni/jni/com_google_espeakengine.cpp View File

@@ -118,9 +118,6 @@ const char *eSpeakSupportedVoices[][3] = {

const int NUM_SUPPORTED_VOICES = 55;

/* Integer constants */
const int DEFAULT_SPEECH_RATE = 150;

// Callback to the TTS API
synthDoneCB_t *ttsSynthDoneCBPointer;

@@ -211,7 +208,6 @@ tts_result attemptInit() {
}

espeak_SetSynthCallback(eSpeakCallback);
espeak_SetParameter(espeakRATE, DEFAULT_SPEECH_RATE, 0);

espeak_VOICE voice;
memset(&voice, 0, sizeof(espeak_VOICE)); // Zero out the voice first
@@ -479,7 +475,8 @@ tts_result TtsEngine::setProperty(const char *property, const char *value, const
// TODO: Set this property
result = EE_OK;
} else if (strncmp(property, "rate", 4) == 0) {
int rate = atoi(value) * DEFAULT_SPEECH_RATE / 100;
int rate = atoi(value) * espeak_GetParameter(espeakRATE, 0) / 100;
if (DEBUG) LOGV("setProperty rate : rate=%s, wpm=%d", value, rate);
result = espeak_SetParameter(espeakRATE, rate, 0);
} else if (strncmp(property, "pitch", 5) == 0) {
int pitch = atoi(value);
@@ -527,7 +524,7 @@ tts_result TtsEngine::getProperty(const char *property, char *value, size_t *ios
}
return TTS_SUCCESS;
} else if (strncmp(property, "rate", 4) == 0) {
int rate = espeak_GetParameter(espeakRATE, 1) * 100 / DEFAULT_SPEECH_RATE;
int rate = espeak_GetParameter(espeakRATE, 1) * 100 / espeak_GetParameter(espeakRATE, 0);
char tmprate[4];
sprintf(tmprate, "%d", rate);
if (*iosize < strlen(tmprate)+1) {

+ 4
- 2
jni/jni/com_googlecode_eyesfree_espeak_eSpeakService.cpp View File

@@ -270,8 +270,10 @@ JNICALL Java_com_googlecode_eyesfree_espeak_SpeechSynthesis_nativeSetVoiceByProp
JNIEXPORT jboolean
JNICALL Java_com_googlecode_eyesfree_espeak_SpeechSynthesis_nativeSetRate(
JNIEnv *env, jobject object, jint rate) {
if (DEBUG) LOGV("%s", __FUNCTION__);
const espeak_ERROR result = espeak_SetParameter(espeakRATE, (int) rate, 0);
const int wpm = ((float)rate / 100) * espeak_GetParameter(espeakRATE, 0);
if (DEBUG) LOGV("%s(rate=%d, wpm=%d)", __FUNCTION__, rate, wpm);

const espeak_ERROR result = espeak_SetParameter(espeakRATE, wpm, 0);

switch (result) {
case EE_OK: return JNI_TRUE;

Loading…
Cancel
Save