mirror of the now-defunct rocklinux.org
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.

118 lines
3.4 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/misc/output/tts/functions.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. # first we will construct a universal 'say' function
  23. function say_proc() {
  24. while read line
  25. do
  26. while read -t1 subline; do
  27. line="$( echo -e "${line%.}.\\n$subline" | tail -n10 )"
  28. done
  29. case "$ROCKCFG_OUTPUT_TTS_SYSTEM" in
  30. ownscript)
  31. echo "${line%.}." | ($ROCKCFG_OUTPUT_TTS_SAYPROG 2>&1) > /dev/null ;;
  32. festival)
  33. echo "${line%.}." | $ROCKCFG_OUTPUT_TTS_FESTIVAL --tts - ;;
  34. mbrola)
  35. echo "${line%.}." | $ROCKCFG_OUTPUT_TTS_TXT2PHO \
  36. | $ROCKCFG_OUTPUT_TTS_MBROLA \
  37. $ROCKCFG_OUTPUT_TTS_VOICEFILE - -.wav \
  38. | $ROCKCFG_OUTPUT_TTS_PLAY ;;
  39. flite)
  40. $ROCKCFG_OUTPUT_TTS_FLITE -t "${line%.}." 2>&1 > /dev/null ;;
  41. esac
  42. done
  43. }
  44. function say() {
  45. if [ -z "$ROCK_OUPUT_PLUGIN_TTS_PROC_ACTIVE" ]; then
  46. export ROCK_OUPUT_PLUGIN_TTS_PROC_ACTIVE=1
  47. exec 198> >( say_proc )
  48. fi
  49. echo "$*" >&198
  50. }
  51. # A free-form header at start of a section usually followed by calls to
  52. # echo_status_terminal().
  53. #
  54. echo_header_tts() {
  55. [ $ROCKCFG_OUTPUT_TTS_ENABLE_HEADER -eq 1 ] && say "$*"
  56. }
  57. # A free-form status message informaing the user of what is happening just
  58. # now.
  59. #
  60. echo_status_tts() {
  61. [ $ROCKCFG_OUTPUT_TTS_ENABLE_STATUS -eq 1 ] && say "$*"
  62. }
  63. # A free-form error or warning message if something fails.
  64. #
  65. echo_error_tts() {
  66. [ $ROCKCFG_OUTPUT_TTS_ENABLE_ERROR -eq 1 ] && say "$*"
  67. }
  68. # We deny to build a package for some reason.
  69. #
  70. # Usage: echo_pkg_deny <stagelevel> <package-name> <reason>
  71. #
  72. echo_pkg_deny_tts() {
  73. [ $ROCKCFG_OUTPUT_TTS_ENABLE_PKG_DENY -eq 1 ] &&
  74. say `eval echo "$ROCKCFG_OUTPUT_TTS_TXT_PKG_DENY"`
  75. }
  76. # We start building a package.
  77. #
  78. # Usage: echo_pkg_start <stagelevel> <repository> <package-name> \
  79. # <ver> <extraver>
  80. #
  81. echo_pkg_start_tts() {
  82. [ $ROCKCFG_OUTPUT_TTS_ENABLE_PKG_START -eq 1 ] &&
  83. say `eval echo "$ROCKCFG_OUTPUT_TTS_TXT_PKG_START"`
  84. }
  85. # We finished building a package.
  86. #
  87. # Usage: echo_pkg_finish <stagelevel> <repository> <package-name>
  88. #
  89. echo_pkg_finish_tts() {
  90. [ $ROCKCFG_OUTPUT_TTS_ENABLE_PKG_FINISH -eq 1 ] &&
  91. say `eval echo "$ROCKCFG_OUTPUT_TTS_TXT_PKG_FINISH"`
  92. }
  93. # We aborted building a package.
  94. #
  95. # Usage: echo_pkg_abort <stagelevel> <repository> <package-name>
  96. #
  97. echo_pkg_abort_tts() {
  98. [ $ROCKCFG_OUTPUT_TTS_ENABLE_PKG_ABORT -eq 1 ] &&
  99. say `eval echo "$ROCKCFG_OUTPUT_TTS_TXT_PKG_ABORT"`
  100. }
  101. # Whenever the tail of error logs are printed, this function is used for
  102. # that. The parameter may contain newlines.
  103. #
  104. echo_errorquote_tts() {
  105. [ $ROCKCFG_OUTPUT_TTS_ENABLE_ERRORQUOTE -eq 1 ] &&
  106. say `eval echo "$ROCKCFG_OUTPUT_TTS_TXT_ERRORQUOTE"`
  107. }