File: print_utterance

package info (click to toggle)
festival-ca 3.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 230,592 kB
  • sloc: xml: 1,949,003; lisp: 50,289; sh: 687; perl: 681; makefile: 513
file content (114 lines) | stat: -rwxr-xr-x 2,608 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/festival --script
;;; Because this is a --script type file it has to explicitly
;;; load the initfiles: init.scm and user's .festivalrc

(set! festlib "../festival/lib")
(set! upclexdir (path-append (car argv) festlib "dicts/upc"))
(set! catalan-path (path-append (car argv) festlib "upc_catalan"))
(set! upc_catalan::debug_token_to_words t)

(if (symbol-bound? 'datadir)
   (load (path-append datadir "init.scm"))
   (load (path-append libdir  "init.scm"))
)
(if (not (member_string catalan-path load-path))
                      (set! load-path (cons catalan-path load-path)))
(require 'upc_catalan)
(require 'upc_catalan_tokenizer)
(set_backtrace t)
(load-catalan-support)

(define (llegeixfitxer fn)
" Obre el fitxer de text fn i el volca en una variable."
  (let ( (fd (fopen fn "r"))
         (content "")
         (entry "")
         (filepos )
       )
       (fseek fd 0 2)
       (set! filepos (ftell fd))
       (fseek fd 0 0)
       (set! content (fread filepos fd))
  (fclose fd)
  content
  )
)

(define (procesa utt)
"Processa una utterance"
(Initialize utt)
(Text utt)
(Token_POS utt)
(Token utt)
(POS utt)
(Phrasify utt)
(Word utt)
(Pauses utt)
;(Intonation utt)
(PostLex utt)
;(Duration utt)
;(Int_Targets utt)
)


(define (imprimeixutt utt1 llistarelacions)
"Imprimeix una utterance."
(let ( (relations "") (relation ""))
(begin
(set! relations llistarelacions)
(while relations
  (set! relation (car relations))
  (set! relations (cdr relations))
  (format t (string-append relation ": \n"))
  (utt.relation.print utt1 relation)
)
))
)

(define (imprimeixutttext texto)
(let (utt1 "")
(begin
(set! utt1 (eval (list (quote Utterance) (quote Text) texto)))
(procesa utt1)
(imprimeixutt utt1)
)
)
)


(set! fitxentrada (car (cdr argv)) )
(if (probe_file fitxentrada)
    (format stderr (string-append "Loading " fitxentrada "\n"))
    (begin
       (format t (string-append "Could not open" fitxentrada "\n"))
       (quit)
    )
)

(set! texto (llegeixfitxer fitxentrada ))
(if (string-matches (path-basename fitxentrada) "full_.*")
  (begin 
      (set! llistatexts (list texto))
      (format stderr "FULL TEXT MODE\n")
  )
  (begin 
      (set! llistatexts (split texto "\n"))
      (format stderr "LINE TEXT MODE\n")
  )
)

(while (> (length llistatexts) 0)
  (set! texto (car llistatexts))
  (format t "Frase: %s\n" texto)
  (format stderr "Frase: %s\n" texto)
  (set! utt1 (eval (list (quote Utterance) (quote Text) texto)))
  (procesa utt1)
  (imprimeixutt utt1 (list "Token" "Word"))
  (format t "\n" )
  (format stderr "\n")
  (set! llistatexts (cdr llistatexts))
)