RE: character substitution. Solution

Subject: RE: character substitution. Solution
From: "Pawson, David" <DPawson@xxxxxxxxxxx>
Date: Wed, 12 Aug 1998 10:18:54 +0100
The following solution works to substitute at the character level.
Many thanks to Tom for his response, clear, concise and accurate.

I have combined it with a 'stretch' function which 
expands 01733 into 0 1 7 3 3, to enable the speech
synth to speak it as seperate digits.

Will try to generalise and put something in for the cookbook later.


;  Substituttion.
(define (subst nl)
  (let loop ((charnodes nl)(result (empty-sosofo)))
    (let* ((firstchar (node-list-first charnodes)))
        ((node-list-empty? firstchar) result)
        ((not (equal? 'data-char (node-property 'classnm firstchar)))
         (loop (node-list-rest charnodes)
               (sosofo-append result (process-node-list firstchar))))
        (#t (let* ((charval (node-property 'char firstchar))
                   (replacement (cond ((equal? charval #\-) #\,)
                                      ((equal? charval #\)) #\,)
                                      ((equal? charval #\() #f)
                                      (#t charval))))
              (loop (node-list-rest charnodes)
                    (sosofo-append result
                                   (if (char? replacement)
                                       (make character
                                             char: replacement)
					(make character ; This append adds
the s p r e a d element.
					     char: #\ )))))))))

> In looking at text->audio preparation using Jade.
> I need to 'clean up' some of the text, such that a 
> text to speech engine  will speak the element content more clearly.
> e.g. <tel>(44) 1733-378-777 </tel>
> becomes <tel>44, 1733,378,777 </tel>

 DSSSList info and archive:

Current Thread