1 <?xml version=
"1.0" encoding=
"UTF-8"?>
3 <!-- ***********************************************************************
5 Stylesheet for transforming SSML into SABLE markup.
7 Copyright : (C) 2004 by Paul Giannaros
9 Original author: Paul Giannaros <ceruleanblaze@gmail.com>
10 ***************************************************************************
12 ***************************************************************************
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; version 2 of the License. *
18 *************************************************************************** -->
19 <!-- @todo create a doc detailing which parts of SSML this sheet can handle -->
21 <xsl:stylesheet version=
"1.0" xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform">
22 <xsl:output method=
"html" indent=
"no"/>
24 <!-- speak: Indicates SSML markup. -->
25 <xsl:template match=
"/speak">
26 <SABLE><xsl:apply-templates/></SABLE>
29 <!-- sub: The word that the text sounds like as abbreviations
30 can be pronounced differently. For example,
31 <sub alias="doctor">Dr.</sub> smith lives at 32 johnson <sub alias="drive">dr.</sub> -->
32 <xsl:template match=
"//sub">
34 <xsl:when test=
"@alias">
35 <xsl:value-of select=
"@alias"/>
38 <xsl:value-of select=
"."/>
43 <!-- p: Indicate a paragraph of text -->
44 <xsl:template match=
"//p">
45 <DIV TYPE=
"paragraph"><xsl:apply-templates/></DIV>
47 <!-- s: Forceefully indicate a sentence (Does not need to be used
48 if full stops are present) -->
49 <xsl:template match=
"//s">
50 <DIV TYPE=
"sentence"><xsl:apply-templates/></DIV>
53 <!-- emphasis: Emphasize a word or group of words. -->
54 <xsl:template match=
"//emphasis">
55 <!-- SSML and SABLE both take the same values for their attributes -
56 strong, moderate, none, reduced -->
57 <EM TYPE=
"{@level}"><xsl:apply-templates/></EM>
60 <xsl:template match=
"//voice">
61 <!-- This is turned off because if Festival lacks an installed voice to match a gender
62 or voice name, it bombs out. argh!
63 <xsl:call-template name="voice"><xsl:with-param name="a" select="@*" /></xsl:call-template> -->
64 <xsl:apply-templates/>
67 <xsl:template name=
"voice">
68 <xsl:param name=
"a" />
69 <!-- Get the name of the tag we're creating and convert to a SABLE tag. -->
70 <xsl:variable name=
"tag">
72 <xsl:when test=
"name($a[1])='gender'">SPEAKER
</xsl:when>
73 <xsl:when test=
"name($a[1])='age'">SPEAKER
</xsl:when>
74 <xsl:when test=
"name($a[1])='name'">SPEAKER
</xsl:when>
75 <xsl:otherwise><xsl:value-of select=
"$a[1]"/></xsl:otherwise>
79 <xsl:element name=
"{$tag}">
80 <!-- Create the right attribute to go with element $tag. -->
84 The gender of the voice.
85 Values such as male, female, and neutral are supported. -->
86 <xsl:when test=
"name($a[1])='gender' and $a[1]='male'">
87 <xsl:attribute name=
"GENDER">male1
</xsl:attribute>
89 <xsl:when test=
"name($a[1])='gender' and $a[1]='female'">
90 <xsl:attribute name=
"GENDER">female1
</xsl:attribute>
92 <!-- If none of the above match, take the users selected value. -->
93 <xsl:when test=
"name($a[1])='gender'">
94 <xsl:attribute name=
"GENDER"><xsl:value-of select=
" $a[1]"/></xsl:attribute>
99 Positive integer values are supported. -->
100 <xsl:when test=
"name($a[1])='age' and number($a[1]) < 10">
101 <xsl:attribute name=
"AGE">child
</xsl:attribute>
103 <xsl:when test=
"name($a[1])='age' and number($a[1]) < 20">
104 <xsl:attribute name=
"AGE">teen
</xsl:attribute>
106 <xsl:when test=
"name($a[1])='age' and number($a[1]) < 30">
107 <xsl:attribute name=
"AGE">younger
</xsl:attribute>
109 <xsl:when test=
"name($a[1])='age' and number($a[1]) < 50">
110 <xsl:attribute name=
"AGE">middle
</xsl:attribute>
112 <xsl:when test=
"name($a[1])='age'">
113 <xsl:attribute name=
"AGE">older
</xsl:attribute>
117 Voice name. Synth dependent. -->
118 <xsl:when test=
"name($a[1])='name'">
119 <xsl:attribute name=
"NAME"><xsl:value-of select=
" $a[1]"/></xsl:attribute>
123 <!-- Recursively call ourself. -->
125 <xsl:when test=
"$a[2]">
126 <xsl:call-template name=
"voice"><xsl:with-param name=
"a" select=
"$a[position()>1]" /></xsl:call-template>
129 <xsl:apply-templates/>
136 <xsl:template match=
"prosody">
137 <!-- contour and duration not supported. -->
138 <xsl:call-template name=
"prosody"><xsl:with-param name=
"a"
139 select=
"@pitch|@rate|@volume|@range" />
143 <xsl:template name=
"prosody">
144 <xsl:param name=
"a" />
145 <!-- Get the name of the tag we're creating and convert to a SABLE tag. -->
146 <xsl:variable name=
"tag">
148 <xsl:when test=
"name($a[1])='pitch'">PITCH
</xsl:when>
149 <xsl:when test=
"name($a[1])='rate'">RATE
</xsl:when>
150 <xsl:when test=
"name($a[1])='volume'">VOLUME
</xsl:when>
151 <xsl:when test=
"name($a[1])='range'">PITCH
</xsl:when>
152 <xsl:otherwise><xsl:value-of select=
"$a[1]"/></xsl:otherwise>
156 <xsl:element name=
"{$tag}">
157 <!-- Create the right attribute to go with element $tag. -->
161 The pitch with which the text is spoken.
162 Values such as x-high, high, low, etc. and percentages (+ or -)
164 <xsl:when test=
"name($a[1])='pitch' and $a[1]='x-high'">
165 <xsl:attribute name=
"BASE">70%
</xsl:attribute>
167 <xsl:when test=
"name($a[1])='pitch' and $a[1]='high'">
168 <xsl:attribute name=
"BASE">40%
</xsl:attribute>
170 <xsl:when test=
"name($a[1])='pitch' and $a[1]='medium'">
171 <xsl:attribute name=
"BASE">0%
</xsl:attribute>
173 <xsl:when test=
"name($a[1])='pitch' and $a[1]='low'">
174 <xsl:attribute name=
"BASE">-
40%
</xsl:attribute>
176 <xsl:when test=
"name($a[1])='pitch' and $a[1]='x-low'">
177 <xsl:attribute name=
"BASE">-
70%
</xsl:attribute>
179 <!-- If none of the above match, take the users selected value. -->
180 <xsl:when test=
"name($a[1])='pitch'">
181 <xsl:attribute name=
"BASE"><xsl:value-of select=
" $a[1]"/></xsl:attribute>
185 The speed at which the text is spoken.
186 Values such as x-fast, fast, slow, etc. and percentages (+ or -)
188 <xsl:when test=
"name($a[1])='rate' and $a[1]='x-fast'">
189 <xsl:attribute name=
"SPEED">70%
</xsl:attribute>
191 <xsl:when test=
"name($a[1])='rate' and $a[1]='fast'">
192 <xsl:attribute name=
"SPEED">40%
</xsl:attribute>
194 <xsl:when test=
"name($a[1])='rate' and $a[1]='medium'">
195 <xsl:attribute name=
"SPEED">0%
</xsl:attribute>
197 <xsl:when test=
"name($a[1])='rate' and $a[1]='slow'">
198 <xsl:attribute name=
"SPEED">-
40%
</xsl:attribute>
200 <xsl:when test=
"name($a[1])='rate' and $a[1]='x-slow'">
201 <xsl:attribute name=
"SPEED">-
70%
</xsl:attribute>
203 <xsl:when test=
"name($a[1])='rate'">
204 <xsl:attribute name=
"SPEED"><xsl:value-of select=
" $a[1]"/></xsl:attribute>
208 The volume at which the text is spoken.
209 Values such as x-loud, loud, quiet, etc. and percentages (+ or -)
211 <xsl:when test=
"name($a[1])='volume' and $a[1]='x-loud'">
212 <xsl:attribute name=
"LEVEL">70%
</xsl:attribute>
214 <xsl:when test=
"name($a[1])='volume' and $a[1]='loud'">
215 <xsl:attribute name=
"LEVEL">50%
</xsl:attribute>
217 <xsl:when test=
"name($a[1])='volume' and $a[1]='medium'">
218 <xsl:attribute name=
"LEVEL">0%
</xsl:attribute>
220 <xsl:when test=
"name($a[1])='volume' and $a[1]='soft'">
221 <xsl:attribute name=
"LEVEL">-
50%
</xsl:attribute>
223 <xsl:when test=
"name($a[1])='volume' and $a[1]='x-soft'">
224 <xsl:attribute name=
"LEVEL">-
70%
</xsl:attribute>
226 <xsl:when test=
"name($a[1])='volume' and $a[1]='silent'">
227 <xsl:attribute name=
"LEVEL">-
100%
</xsl:attribute>
229 <xsl:when test=
"name($a[1])='volume'">
230 <xsl:attribute name=
"LEVEL"><xsl:value-of select=
" $a[1]"/></xsl:attribute>
234 The volume at which the text is spoken.
235 Values such as x-high, high, medium, low, x-low, etc. and percentages (+ or -)
237 <xsl:when test=
"name($a[1])='range' and $a[1]='x-high'">
238 <xsl:attribute name=
"RANGE">70%
</xsl:attribute>
240 <xsl:when test=
"name($a[1])='range' and $a[1]='high'">
241 <xsl:attribute name=
"RANGE">40%
</xsl:attribute>
243 <xsl:when test=
"name($a[1])='range' and $a[1]='medium'">
244 <xsl:attribute name=
"RANGE">0%
</xsl:attribute>
246 <xsl:when test=
"name($a[1])='range' and $a[1]='low'">
247 <xsl:attribute name=
"RANGE">-
40%
</xsl:attribute>
249 <xsl:when test=
"name($a[1])='range' and $a[1]='x-low'">
250 <xsl:attribute name=
"RANGE">-
70%
</xsl:attribute>
252 <!-- If none of the above match, take the users selected value. -->
253 <xsl:when test=
"name($a[1])='range'">
254 <xsl:attribute name=
"RANGE"><xsl:value-of select=
" $a[1]"/></xsl:attribute>
259 <!-- Recursively call ourself. -->
261 <xsl:when test=
"$a[2]">
262 <xsl:call-template name=
"prosody"><xsl:with-param name=
"a" select=
"$a[position()>1]" /></xsl:call-template>
265 <xsl:apply-templates/>