Browse Source

ssml: support break time multiplier

master
Yury Popov 2 years ago
parent
commit
8e163d5072
No account linked to committer's email address

+ 9
- 0
src/espeak-ng.c View File

"\t Write speech to this WAV file, rather than speaking it directly\n" "\t Write speech to this WAV file, rather than speaking it directly\n"
"-b\t Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit \n" "-b\t Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit \n"
"-m\t Interpret SSML markup, and ignore other < > tags\n" "-m\t Interpret SSML markup, and ignore other < > tags\n"
"--ssml-break=<percentage>\n"
"\t Set SSML break time multiplier, default is 100\n"
"-q\t Quiet, don't produce any speech (may be useful with -x)\n" "-q\t Quiet, don't produce any speech (may be useful with -x)\n"
"-x\t Write phoneme mnemonics to stdout\n" "-x\t Write phoneme mnemonics to stdout\n"
"-X\t Write phonemes mnemonics and translation trace to stdout\n" "-X\t Write phonemes mnemonics and translation trace to stdout\n"
{ "compile-intonations", no_argument, 0, 0x10f }, { "compile-intonations", no_argument, 0, 0x10f },
{ "compile-phonemes", optional_argument, 0, 0x110 }, { "compile-phonemes", optional_argument, 0, 0x110 },
{ "load", no_argument, 0, 0x111 }, { "load", no_argument, 0, 0x111 },
{ "ssml-break", required_argument, 0, 0x112 },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };


int phoneme_options = 0; int phoneme_options = 0;
int option_linelength = 0; int option_linelength = 0;
int option_waveout = 0; int option_waveout = 0;
int ssml_break = -1;
bool deterministic = 0; bool deterministic = 0;
espeak_VOICE voice_select; espeak_VOICE voice_select;
case 0x111: // --load case 0x111: // --load
flag_load = 1; flag_load = 1;
break; break;
case 0x112: // --ssml-break
ssml_break = atoi(optarg2);
break;
default: default:
exit(0); exit(0);
} }
espeak_SetParameter(espeakWORDGAP, wordgap, 0); espeak_SetParameter(espeakWORDGAP, wordgap, 0);
if (option_linelength > 0) if (option_linelength > 0)
espeak_SetParameter(espeakLINELENGTH, option_linelength, 0); espeak_SetParameter(espeakLINELENGTH, option_linelength, 0);
if (ssml_break > 0)
espeak_SetParameter(espeakSSML_BREAK_MUL, ssml_break, 0);
if (option_punctuation == 2) if (option_punctuation == 2)
espeak_SetPunctuationList(option_punctlist); espeak_SetPunctuationList(option_punctlist);



+ 1
- 1
src/include/espeak-ng/speak_lib.h View File

espeakWORDGAP=7, espeakWORDGAP=7,
espeakOPTIONS=8, // reserved for misc. options. not yet used espeakOPTIONS=8, // reserved for misc. options. not yet used
espeakINTONATION=9, espeakINTONATION=9,
espeakSSML_BREAK_MUL=10,


espeakRESERVED1=10,
espeakRESERVED2=11, espeakRESERVED2=11,
espeakEMPHASIS, /* internal use */ espeakEMPHASIS, /* internal use */
espeakLINELENGTH, /* internal use */ espeakLINELENGTH, /* internal use */

+ 2
- 0
src/libespeak-ng/setlengths.c View File

translator->langopts.intonation_group = new_value & 0xff; translator->langopts.intonation_group = new_value & 0xff;
option_tone_flags = new_value; option_tone_flags = new_value;
break; break;
case espeakSSML_BREAK_MUL:
break;
default: default:
return EINVAL; return EINVAL;
} }

+ 1
- 1
src/libespeak-ng/speech.c View File

0, // wordgap 0, // wordgap
0, // options 0, // options
0, // intonation 0, // intonation
0,
100, // ssml break mul
0, 0,
0, // emphasis 0, // emphasis
0, // line length 0, // line length

+ 2
- 0
src/libespeak-ng/ssml.c View File

if ((attr2 = GetSsmlAttribute(px, "time")) != NULL) { if ((attr2 = GetSsmlAttribute(px, "time")) != NULL) {
value2 = attrnumber(attr2, 0, 1); // pause in mS value2 = attrnumber(attr2, 0, 1); // pause in mS


value2 = value2 * speech_parameters[espeakSSML_BREAK_MUL] / 100;

int wpm = speech_parameters[espeakRATE]; int wpm = speech_parameters[espeakRATE];
espeak_SetParameter(espeakRATE, wpm, 0); espeak_SetParameter(espeakRATE, wpm, 0);



+ 5
- 1
tests/ssml.test View File

TEST_NAME=$1 TEST_NAME=$1
EXPECTED=$2 EXPECTED=$2
TEST_TEXT=$3 TEST_TEXT=$3
OPTS=$4


echo "testing ${TEST_NAME}" echo "testing ${TEST_NAME}"
ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \ ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
$VALGRIND src/espeak-ng --stdout -m "${TEST_TEXT}" \
$VALGRIND src/espeak-ng --stdout -m "${TEST_TEXT}" ${OPTS} \
> actual.txt || exit 1 > actual.txt || exit 1
< actual.txt $sha1sum | awk '{ print $1 }' > sum.txt < actual.txt $sha1sum | awk '{ print $1 }' > sum.txt
echo "${EXPECTED}" > expected.txt echo "${EXPECTED}" > expected.txt
( test_ssml_audio "<prosody 260%><break 1000ms>" 4b4e30a2cfff1889972f013e514e81c1108283a4 "<speak><prosody rate=\"260%\">Break<break time=\"1000ms\"/>test</prosody></speak>" ) || \ ( test_ssml_audio "<prosody 260%><break 1000ms>" 4b4e30a2cfff1889972f013e514e81c1108283a4 "<speak><prosody rate=\"260%\">Break<break time=\"1000ms\"/>test</prosody></speak>" ) || \
( test_ssml_audio "<prosody 260%><break 1000ms>" 9849f0d27f5641db6da1a8aea82578e83656d323 "<speak><prosody rate=\"260%\">Break<break time=\"1000ms\"/>test</prosody></speak>" ) || \ ( test_ssml_audio "<prosody 260%><break 1000ms>" 9849f0d27f5641db6da1a8aea82578e83656d323 "<speak><prosody rate=\"260%\">Break<break time=\"1000ms\"/>test</prosody></speak>" ) || \
( test_ssml_audio "<prosody 260%><break 1000ms>" 32a9c2887ec5b7d9d33d5503518ac0d384e43448 "<speak><prosody rate=\"260%\">Break<break time=\"1000ms\"/>test</prosody></speak>" ) || exit 1 ( test_ssml_audio "<prosody 260%><break 1000ms>" 32a9c2887ec5b7d9d33d5503518ac0d384e43448 "<speak><prosody rate=\"260%\">Break<break time=\"1000ms\"/>test</prosody></speak>" ) || exit 1

# Test break multiplier
test_ssml_audio "<break 1000ms> mul=10" 9f3b0f34eb605fcecfc573fc215626f634b46756 "<speak>Break<break time=\"1000ms\"/>test</speak>" "--ssml-break=10"

Loading…
Cancel
Save