play_sync.scm 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;; ;;;
  3. ;;; Language Technologies Institute ;;;
  4. ;;; Carnegie Mellon University ;;;
  5. ;;; Copyright (c) 2000 ;;;
  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. ;;; CARNEGIE MELLON UNIVERSITY 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 CARNEGIE MELLON UNIVERSITY 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 (awb@cs.cmu.edu) ;;;
  34. ;;; Date: September 2000 ;;;
  35. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  36. ;;; ;;;
  37. ;;; Display as we go synthesis ;;;
  38. ;;; ;;;
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  40. (defvar play_sync_program "/home/awb/projects/flite/testsuite/play_sync")
  41. (define (display_as_we_go file filemode)
  42. "(display_as_we_go file filemode)
  43. Display the words as we synthesize them."
  44. (set! tts_hooks
  45. (list utt.synth utt.play_display))
  46. (tts_file file filemode)
  47. (format t "\n\n"))
  48. (define (utt.play_display utt)
  49. "(utt.play_display utt)
  50. Play and display."
  51. (let ((tmpwave (make_tmp_filename))
  52. (tmpword (make_tmp_filename)))
  53. (utt.save.wave utt tmpwave 'riff)
  54. (utt.save.play_words utt tmpword)
  55. ; (utt.save.segs utt tmpword)
  56. (system (format nil "%s %s %s" play_sync_program tmpwave tmpword))
  57. (delete-file tmpwave)
  58. (delete-file tmpword)
  59. utt))
  60. (define (utt.save.play_words utt filename)
  61. "(utt.save.play_words UTT FILE)
  62. Save words of UTT in a FILE in xlabel format, wityh added __silence__."
  63. (let ((fd (fopen filename "w")))
  64. (format fd "#\n")
  65. (mapcar
  66. (lambda (w)
  67. (if (string-equal
  68. (item.feat w "R:SylStructure.daughter1.daughter1.R:Segment.p.name")
  69. (car (cadr (car (PhoneSet.description '(silences))))))
  70. (format fd "%2.4f 100 %s\n"
  71. (item.feat w "R:SylStructure.daughter1.daughter1.R:Segment.p.end")
  72. "__silence__"))
  73. (format fd "%2.4f 100 %s\n" (item.feat w "word_end")
  74. (item.name w)))
  75. (utt.relation.items utt 'Word))
  76. (fclose fd)
  77. utt))
  78. (provide 'play_sync)