home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / fest-141.zip / festival / examples / text2pos.sh < prev    next >
Text File  |  1999-09-09  |  4KB  |  82 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-*-mode:scheme-*-
  2. ;;                                                                       ;;
  3. ;;                Centre for Speech Technology Research                  ;;
  4. ;;                     University of Edinburgh, UK                       ;;
  5. ;;                       Copyright (c) 1996,1997                         ;;
  6. ;;                        All Rights Reserved.                           ;;
  7. ;;                                                                       ;;
  8. ;;  Permission is hereby granted, free of charge, to use and distribute  ;;
  9. ;;  this software and its documentation without restriction, including   ;;
  10. ;;  without limitation the rights to use, copy, modify, merge, publish,  ;;
  11. ;;  distribute, sublicense, and/or sell copies of this work, and to      ;;
  12. ;;  permit persons to whom this work is furnished to do so, subject to   ;;
  13. ;;  the following conditions:                                            ;;
  14. ;;   1. The code must retain the above copyright notice, this list of    ;;
  15. ;;      conditions and the following disclaimer.                         ;;
  16. ;;   2. Any modifications must be clearly marked as such.                ;;
  17. ;;   3. Original authors' names are not deleted.                         ;;
  18. ;;   4. The authors' names are not used to endorse or promote products   ;;
  19. ;;      derived from this software without specific prior written        ;;
  20. ;;      permission.                                                      ;;
  21. ;;                                                                       ;;
  22. ;;  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        ;;
  23. ;;  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      ;;
  24. ;;  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   ;;
  25. ;;  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     ;;
  26. ;;  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    ;;
  27. ;;  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   ;;
  28. ;;  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          ;;
  29. ;;  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       ;;
  30. ;;  THIS SOFTWARE.                                                       ;;
  31. ;;                                                                       ;;
  32. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  33. ;;;           Author:  Alan W Black
  34. ;;;           Date:    August 1996
  35. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  36. ;;;
  37. ;;;  Reads in text from stdin and outputs text/pos on stdout
  38. ;;;
  39. ;;;  Designed to show how simple filters can be written in Festival
  40. ;;;
  41. ;;;  First we defined a function that processes an utterance enough
  42. ;;;  to predict part of speech, namely, tokenize it, find the words
  43. ;;;  and then run the POS tagger on it.
  44. ;;;  Then we define a function to extract the word and pos tag itself
  45. ;;;
  46. ;;;  We redefine the basic functions run on utterances during text to
  47. ;;;  speech to be our two newly-defined function and then simply
  48. ;;;  run tts on standard input.
  49. ;;;
  50.  
  51. ;;; Because this is a --script type file I has to explicitly
  52. ;;; load the initfiles: init.scm and user's .festivalrc
  53. (load (path-append libdir "init.scm"))
  54.  
  55. (define (find-pos utt)
  56. "Main function for processing TTS utterances.  Predicts POS and
  57. prints words with their POS"
  58.   (Token utt)
  59.   (POS utt)
  60. )
  61.  
  62. (define (output-pos utt)
  63. "Output the word/pos for each word in utt"
  64.  (mapcar
  65.   (lambda (pair)
  66.     (format t "%l/%l\n" (car pair) (car (cdr pair))))
  67.   (utt.features utt 'Word '(name pos))))
  68.  
  69. ;;;
  70. ;;; Redefine what happens to utterances during text to speech 
  71. ;;;
  72. (set! tts_hooks (list find-pos output-pos))
  73.  
  74. ;;; Stop those GC messages
  75. (gc-status nil)
  76.  
  77. ;;; Do the work
  78. (tts_file "-")
  79.  
  80.  
  81.  
  82.