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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 Klatt synthesizer is installed
  23. is_klatt() {
  24. echo -n "checking if klatt is installed ... "
  25. if [ "`which klatt`" != "" ]; then
  26. echo "yes"
  27. else
  28. echo "no"
  29. exit
  30. fi
  31. }
  32. # test if MBROLA synthesizer is installed
  33. is_mbrola() {
  34. echo -n "checking if MBROLA is installed ... "
  35. if [ "`which mbrola`" != "" ]; then
  36. echo "yes"
  37. else
  38. echo "no"
  39. exit
  40. fi
  41. }
  42. # Check processed text by phonetic representation of the output
  43. test_phon() {
  44. TEST_LANG=$1
  45. EXPECTED=$2
  46. TEST_TEXT=$3
  47. MESSAGE=$4
  48. OPTIONS=$5
  49. if [ "$MESSAGE" = "" ] ; then
  50. MESSAGE=$TEST_TEXT
  51. fi
  52. echo "testing ${TEST_LANG} $MESSAGE"
  53. ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
  54. src/espeak-ng -xq ${OPTIONS} -v ${TEST_LANG} "${TEST_TEXT}" > actual.txt
  55. echo "${EXPECTED}" > expected.txt
  56. if [ "$MESSAGE" = "Ignore" ] ; then
  57. diff expected.txt actual.txt || (echo "... ignoring error" && true)
  58. else
  59. diff expected.txt actual.txt || exit 1
  60. fi
  61. }
  62. # Check generated wav file from processed text
  63. test_wav () {
  64. VOICE=$1
  65. EXPECTED=$2
  66. TEST_TEXT=$3
  67. MESSAGE=$4
  68. echo "testing ${VOICE}${MESSAGE}"
  69. ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
  70. src/espeak-ng --stdout -v ${VOICE} "${TEST_TEXT}" | \
  71. $sha1sum | awk '{ print $1 }' > actual.txt
  72. echo "${EXPECTED}" > expected.txt
  73. if [ "$MESSAGE" = "Ignore" ] ; then
  74. diff expected.txt actual.txt || (echo "... ignoring error" && true)
  75. else
  76. diff expected.txt actual.txt || exit 1
  77. fi
  78. }
  79. # Check generated wav file from processed text, where $EXPECTED is grep string
  80. test_wav_grep () {
  81. VOICE=$1
  82. EXPECTED=$2
  83. TEST_TEXT=$3
  84. MESSAGE=$4
  85. echo "testing ${VOICE}${MESSAGE}"
  86. ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
  87. src/espeak-ng --stdout -v ${VOICE} "${TEST_TEXT}" | \
  88. $sha1sum | awk '{ print $1 }' > actual.txt
  89. if [ "$MESSAGE" = "Ignore" ] ; then
  90. cat actual.txt | grep -E "$EXPECTED" || (echo "... ignoring error" && true)
  91. else
  92. cat actual.txt | grep -E "$EXPECTED" || { printf "wrong hash: "; cat actual.txt; exit 1; }
  93. fi
  94. }
  95. # Check generated wav file from list of phonemes
  96. test_phwav() {
  97. TEST_LANG=$1
  98. EXPECTED=$2
  99. TEST_TEXT=$3
  100. test_wav $TEST_LANG $EXPECTED "[[$TEST_TEXT]]"
  101. }
  102. test_replace() {
  103. TEST_LANG=$1
  104. TEST_TEXT=$2
  105. MESSAGE=$3
  106. if [ "$MESSAGE" = "" ] ; then
  107. MESSAGE=$TEST_TEXT
  108. fi
  109. echo "testing ${TEST_LANG}"
  110. ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
  111. src/espeak-ng -Xq -v ${TEST_LANG} "${TEST_TEXT}" | grep -E "(Translate|Found:) " | sed -e 's/ \[.*][ ]*$//g' > actual.txt
  112. if [ "$MESSAGE" = "Ignore" ] ; then
  113. diff expected.txt actual.txt || (echo "... ignoring error" && true)
  114. else
  115. diff expected.txt actual.txt || exit 1
  116. fi
  117. }