eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/bin/sh
  2. # Test a command for presence and ability to output the sha1 hash of a file
  3. is_hash() {
  4. echo -n "checking for SHA1 hashing command ... "
  5. if check_hash sha1sum; then
  6. sha1sum=sha1sum
  7. elif check_hash sha1; then
  8. sha1sum=sha1
  9. elif check_hash shasum; then
  10. sha1sum=shasum
  11. else
  12. echo "no"
  13. exit 1
  14. fi
  15. }
  16. check_hash() {
  17. which $1 &&
  18. $1 </dev/null 2>/dev/null |
  19. awk '{if ($1 != "da39a3ee5e6b4b0d3255bfef95601890afd80709") { exit 1; }}'
  20. # Test some common commands to find the correct one for the system being tested on.
  21. }
  22. # test if MBROLA synthesizer is installed
  23. is_mbrola() {
  24. echo -n "checking if MBROLA is installed ... "
  25. if [ "`which mbrola`" != "" ]; then
  26. echo "yes"
  27. else
  28. echo "no"
  29. exit
  30. fi
  31. }
  32. # Check processed text by phonetic representation of the output
  33. test_phon() {
  34. TEST_LANG=$1
  35. EXPECTED=$2
  36. TEST_TEXT=$3
  37. MESSAGE=$4
  38. OPTIONS=$5
  39. if [ "$MESSAGE" = "" ] ; then
  40. MESSAGE=$TEST_TEXT
  41. fi
  42. echo "testing ${TEST_LANG} $MESSAGE"
  43. ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
  44. $VALGRIND src/espeak-ng -xq ${OPTIONS} -v ${TEST_LANG} "${TEST_TEXT}" \
  45. > actual.txt || exit 1
  46. echo "${EXPECTED}" > expected.txt
  47. if [ "$MESSAGE" = "Ignore" ] ; then
  48. diff expected.txt actual.txt || (echo "... ignoring error" && true)
  49. else
  50. diff expected.txt actual.txt || exit 1
  51. fi
  52. }
  53. # Check generated wav file from processed text
  54. test_wav () {
  55. VOICE=$1
  56. EXPECTED=$2
  57. TEST_TEXT=$3
  58. MESSAGE=$4
  59. echo "testing ${VOICE}${MESSAGE}"
  60. ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
  61. $VALGRIND src/espeak-ng -D --stdout -v ${VOICE} "${TEST_TEXT}" \
  62. > actual.txt || exit 1
  63. < actual.txt $sha1sum | awk '{ print $1 }' > sum.txt
  64. echo "${EXPECTED}" > expected.txt
  65. if [ "$MESSAGE" = "Ignore" ] ; then
  66. diff expected.txt sum.txt || (echo "... ignoring error" && true)
  67. else
  68. diff expected.txt sum.txt || exit 1
  69. fi
  70. }
  71. # Check generated wav file from processed text, where $EXPECTED is grep string
  72. test_wav_grep () {
  73. VOICE=$1
  74. EXPECTED=$2
  75. TEST_TEXT=$3
  76. MESSAGE=$4
  77. echo "testing ${VOICE}${MESSAGE}"
  78. ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
  79. $VALGRIND src/espeak-ng -D --stdout -v ${VOICE} "${TEST_TEXT}" \
  80. > actual.txt || exit 1
  81. < actual.txt $sha1sum | awk '{ print $1 }' > sum.txt
  82. if [ "$MESSAGE" = "Ignore" ] ; then
  83. cat sum.txt | grep -E "$EXPECTED" || (echo "... ignoring error" && true)
  84. else
  85. cat sum.txt | grep -E "$EXPECTED" || { printf "wrong hash: "; cat sum.txt; exit 1; }
  86. fi
  87. }
  88. # Check generated wav file from list of phonemes
  89. test_phwav() {
  90. TEST_LANG=$1
  91. EXPECTED=$2
  92. TEST_TEXT=$3
  93. test_wav $TEST_LANG $EXPECTED "[[$TEST_TEXT]]"
  94. }
  95. test_replace() {
  96. TEST_LANG=$1
  97. TEST_TEXT=$2
  98. MESSAGE=$3
  99. if [ "$MESSAGE" = "" ] ; then
  100. MESSAGE=$TEST_TEXT
  101. fi
  102. echo "testing ${TEST_LANG}"
  103. ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
  104. $VALGRIND src/espeak-ng -Xq -v ${TEST_LANG} "${TEST_TEXT}" \
  105. > actual.txt || exit 1
  106. < actual.txt grep -a -E "(Translate|Found:) " | sed -e 's/ \[.*][ ]*$//g' > filtered.txt
  107. if [ "$MESSAGE" = "Ignore" ] ; then
  108. diff expected.txt filtered.txt || (echo "... ignoring error" && true)
  109. else
  110. diff expected.txt filtered.txt || exit 1
  111. fi
  112. }