|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (Pauses utt) |
|
"(Pauses utt) |
|
Insert pauses where required." |
|
(let ((rval (apply_method 'Pause_Method utt))) |
|
(cond |
|
(rval rval) |
|
(t |
|
(Classic_Pauses utt)))) |
|
(Pause_optional_deleting_B_X utt)) |
|
|
|
(define (Classic_Pauses utt) |
|
"(Pauses UTT) |
|
Predict pause insertion." |
|
(let ((words (utt.relation.items utt 'Word)) lastword tpname) |
|
(if words |
|
(begin |
|
(insert_initial_pause utt) |
|
(set! lastword (car (last words))) |
|
(mapcar |
|
(lambda (w) |
|
(let ((pbreak (item.feat w "pbreak")) |
|
(emph (item.feat w "R:Token.parent.EMPH"))) |
|
(cond |
|
((or (string-equal "B" pbreak) |
|
(string-equal "BB" pbreak)) |
|
(insert_pause utt w)) |
|
|
|
|
|
((equal? w lastword) |
|
(insert_pause utt w))))) |
|
words) |
|
|
|
(mapcar |
|
(lambda (w) |
|
(let ((pos (item.feat w "pos"))) |
|
(if (or (string-equal "punc" pos) |
|
(string-equal "fpunc" pos)) |
|
(let ((pbreak (item.feat w "pbreak")) |
|
(wp (item.relation w 'Phrase))) |
|
(if (and (string-matches pbreak "BB?") |
|
(item.relation.prev w 'Word)) |
|
(item.set_feat |
|
(item.relation.prev w 'Word) "pbreak" pbreak)) |
|
(item.relation.remove w 'Word) |
|
|
|
(item.relation.remove wp 'Phrase))))) |
|
words) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(set! sil (car (car (cdr (car (PhoneSet.description '(silences))))))) |
|
(set! seg (item.next(utt.relation.first utt 'Segment))) |
|
(while seg |
|
(if(and(equal? sil (item.name seg)) |
|
(equal? sil (item.name (item.prev seg)))) |
|
(item.delete (item.prev seg))) |
|
(set! seg (item.next seg))))) |
|
utt)) |
|
|
|
(define (insert_pause utt word) |
|
"(insert_pause UTT WORDITEM) |
|
Insert a silence segment after the last segment in WORDITEM in UTT." |
|
(let ((lastseg (find_last_seg word)) |
|
(silence (car (car (cdr (car (PhoneSet.description '(silences)))))))) |
|
(if lastseg |
|
(item.relation.insert |
|
lastseg 'Segment (list silence) 'after)))) |
|
|
|
(define (insert_initial_pause utt) |
|
"(insert_initial_pause UTT) |
|
Always have an initial silence if the utterance is non-empty. |
|
Insert a silence segment after the last segment in WORDITEM in UTT." |
|
(let ((firstseg (car (utt.relation.items utt 'Segment))) |
|
(silence (car (car (cdr (car (PhoneSet.description '(silences)))))))) |
|
(if firstseg |
|
(item.relation.insert |
|
firstseg 'Segment (list silence) 'before)))) |
|
|
|
(define (insert_final_pause utt) |
|
"(insert_final_pause UTT) |
|
Always have a final silence if the utterance is non-empty." |
|
(let ((lastseg (utt.relation.last utt 'Segment)) |
|
(silence (car (car (cdr (car (PhoneSet.description '(silences)))))))) |
|
(set! silence (format nil "%l" silence)) |
|
|
|
|
|
(if lastseg |
|
(if (not(equal? (item.name lastseg) silence)) |
|
(begin |
|
(format t "iserted final pause %s\n" silence) |
|
(item.relation.insert lastseg 'Segment (list silence) 'after)))))) |
|
|
|
|
|
(define (find_last_seg word) |
|
|
|
|
|
|
|
(cond |
|
((null word) |
|
nil) |
|
(t |
|
(let ((lsyl (item.relation.daughtern word 'SylStructure))) |
|
(if lsyl |
|
(item.relation.daughtern lsyl 'SylStructure) |
|
(find_last_seg (item.relation.prev word 'Word))))))) |
|
|
|
(define (Unisyn_Pauses utt) |
|
"(Unisyn_Pauses UTT) |
|
Predict pause insertion in a Unisyn utterance structure." |
|
(let ((words (utt.relation.items utt 'Word)) lastword tpname) |
|
(if words |
|
(begin |
|
(us_insert_initial_pause utt) |
|
(set! lastword (car (last words))) |
|
(mapcar |
|
(lambda (w) |
|
(let ((pbreak (item.feat w "pbreak")) |
|
(emph (item.feat w "R:Token.parent.EMPH"))) |
|
(cond |
|
((or (string-equal "B" pbreak) |
|
(string-equal "BB" pbreak)) |
|
(us_insert_pause utt w)) |
|
|
|
|
|
((equal? w lastword) |
|
(us_insert_pause utt w))))) |
|
words) |
|
|
|
(mapcar |
|
(lambda (w) |
|
(let ((pos (item.feat w "pos"))) |
|
(if (or (string-equal "punc" pos) |
|
(string-equal "fpunc" pos)) |
|
(let ((pbreak (item.feat w "pbreak")) |
|
(wp (item.relation w 'Phrase))) |
|
(if (and (string-matches pbreak "BB?") |
|
(item.relation.prev w 'Word)) |
|
(item.set_feat |
|
(item.relation.prev w 'Word) "pbreak" pbreak)) |
|
(item.relation.remove w 'Word) |
|
|
|
(item.relation.remove wp 'Phrase))))) |
|
words))) |
|
utt)) |
|
|
|
(define (us_insert_pause utt word) |
|
"(us_insert_pause UTT WORDITEM) |
|
Insert a silence segment after the last segment in WORDITEM in UTT." |
|
(let ((lastseg (us_find_last_seg word)) |
|
(silence "pau")) |
|
(if lastseg |
|
(item.relation.insert |
|
lastseg 'Segment (list silence) 'after)))) |
|
|
|
(define (us_insert_initial_pause utt) |
|
"(us_insert_initial_pause UTT) |
|
Always have an initial silence if the utterance is non-empty. |
|
Insert a silence segment after the last segment in WORDITEM in UTT." |
|
(let ((firstseg (utt.relation.first utt 'Segment)) |
|
(silence "pau")) |
|
(if firstseg |
|
(item.relation.insert |
|
firstseg 'Segment (list silence) 'before)))) |
|
|
|
(define (us_find_last_seg word) |
|
|
|
|
|
|
|
(cond |
|
((null word) |
|
nil) |
|
(t |
|
(if (item.daughtern_to (item.relation word 'WordStructure) 'Syllable) |
|
(item.daughtern_to |
|
(item.relation |
|
(item.daughtern_to (item.relation word 'WordStructure) 'Syllable) |
|
'SylStructure) |
|
'Segment) |
|
(us_find_last_seg (item.relation.prev word 'Word)))))) |
|
|
|
(define (Pause_optional_deleting_B_X utt) |
|
"(Pause_optional_deleting_B_X utt) |
|
|
|
Delete all phone symbols starting with 'B_' from the segemt relation |
|
(a B_150 e.g. is a 150ms pause) if symbol 'Pause_delete_B_X is defined. |
|
" |
|
|
|
|
|
|
|
|
|
(if (symbol-bound? 'Pause_delete_B_X) |
|
(let(seg ) |
|
(set! seg (item.next(utt.relation.first utt 'Segment))) |
|
(while seg |
|
(set! next_seg (item.next seg)) |
|
|
|
(if(string-matches (item.name seg) "B_[0-9]*") |
|
(item.delete seg)) |
|
(set! seg next_seg))))) |
|
|
|
(provide 'pauses) |
|
|