diff --git a/.gitignore b/.gitignore index cccd6a58..50c3adf4 100644 --- a/.gitignore +++ b/.gitignore @@ -111,6 +111,7 @@ tests/*.check !tests/translate.test !tests/non-executable-files-with-executable-bit.test !tests/bom.test +!tests/mbrola.test espeak-ng.pc diff --git a/Makefile.am b/Makefile.am index 46620321..55428b32 100644 --- a/Makefile.am +++ b/Makefile.am @@ -257,6 +257,7 @@ check: tests/encoding.check \ tests/language-numbers-cardinal.check \ tests/language-numbers-ordinal.check \ tests/non-executable-files-with-executable-bit.check \ + tests/mbrola.check \ tests/bom.check ##### fuzzer: diff --git a/tests/mbrola.test b/tests/mbrola.test new file mode 100755 index 00000000..a945f7f9 --- /dev/null +++ b/tests/mbrola.test @@ -0,0 +1,63 @@ +#!/bin/sh +# Test a command for presence and ability to output the sha1 hash of a file. +check_hashcmd() { + which $1 && + $1 /dev/null | + awk '{if ($1 != "da39a3ee5e6b4b0d3255bfef95601890afd80709") { exit 1; }}' +} + +check_voice_folder() { + voice_file=${1#mb-} + if [ -f "/usr/share/mbrola/$voice_file" ]; then + voice_file="/usr/share/mbrola/$voice_file" + elif [ -f "/usr/share/mbrola/$voice_file/$voice_file" ]; then + voice_file="/usr/share/mbrola/$voice_file/$voice_file" + elif [ -f "/usr/share/mbrola/voices/$voice_file" ]; then + voice_file="/usr/share/mbrola/voices/$voice_file" + else + voice_file="" + fi +} + +test_voice () { + MBVOICE=$1 + EXPECTED=$2 + TEST_TEXT=$3 + check_voice_folder $MBVOICE + if [ "$voice_file" != "" ]; then + echo "testing ${MBVOICE} ${TEST_TEXT} ... " + ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \ + src/espeak-ng --stdout -v ${MBVOICE} "${TEST_TEXT}" | \ + $sha1sum | awk '{ print $1 }' > actual.txt + echo "${EXPECTED}" > expected.txt + diff expected.txt actual.txt || exit 1 + else + echo "$MBVOICE was not tested" + fi +} + +# Test some common commands to find the correct one for the system being tested on. +echo -n "checking for SHA1 hashing command ... " +if check_hashcmd sha1sum; then + sha1sum=sha1sum +elif check_hashcmd sha1; then + sha1sum=sha1 +elif check_hashcmd shasum; then + sha1sum=shasum +else + echo "no" + exit 1 +fi + + +echo -n "checking if MBROLA is installed ... " +if [ "`which mbrola`" != "" ]; then + echo "yes" +else + echo "no" + exit 1 +fi + +test_voice mb-fr4 31fae066f45d4a9dc56289344f28dd00bce77875 "Bonjour" + +