mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-07 07:23:52 +00:00
Fix the pitch mapping between Android and eSpeak.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user