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



const int NUM_SUPPORTED_VOICES = 55; const int NUM_SUPPORTED_VOICES = 55;


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

// Callback to the TTS API // Callback to the TTS API
synthDoneCB_t *ttsSynthDoneCBPointer; synthDoneCB_t *ttsSynthDoneCBPointer;


} }


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


espeak_VOICE voice; espeak_VOICE voice;
memset(&voice, 0, sizeof(espeak_VOICE)); // Zero out the voice first memset(&voice, 0, sizeof(espeak_VOICE)); // Zero out the voice first
// TODO: Set this property // TODO: Set this property
result = EE_OK; result = EE_OK;
} else if (strncmp(property, "rate", 4) == 0) { } 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); result = espeak_SetParameter(espeakRATE, rate, 0);
} else if (strncmp(property, "pitch", 5) == 0) { } else if (strncmp(property, "pitch", 5) == 0) {
int pitch = atoi(value); int pitch = atoi(value);
} }
return TTS_SUCCESS; return TTS_SUCCESS;
} else if (strncmp(property, "rate", 4) == 0) { } 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]; char tmprate[4];
sprintf(tmprate, "%d", rate); sprintf(tmprate, "%d", rate);
if (*iosize < strlen(tmprate)+1) { if (*iosize < strlen(tmprate)+1) {

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

JNIEXPORT jboolean JNIEXPORT jboolean
JNICALL Java_com_googlecode_eyesfree_espeak_SpeechSynthesis_nativeSetRate( JNICALL Java_com_googlecode_eyesfree_espeak_SpeechSynthesis_nativeSetRate(
JNIEnv *env, jobject object, jint rate) { 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) { switch (result) {
case EE_OK: return JNI_TRUE; case EE_OK: return JNI_TRUE;

Loading…
Cancel
Save