SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / kttsd / plugins / festivalint / SSMLtoSable.xsl
blob48c2fd0c7ef1dba5c35075a67e699ac82bb397ff
1 <?xml version="1.0" encoding="UTF-8"?>
3 <!-- ***********************************************************************
4 SSMLtoSable.xsl
5 Stylesheet for transforming SSML into SABLE markup.
6 ============
7 Copyright : (C) 2004 by Paul Giannaros
8 ============
9 Original author: Paul Giannaros <ceruleanblaze@gmail.com>
10 ***************************************************************************
12 ***************************************************************************
13 * *
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. *
17 * *
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>
27 </xsl:template>
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">
33 <xsl:choose>
34 <xsl:when test="@alias">
35 <xsl:value-of select="@alias"/>
36 </xsl:when>
37 <xsl:otherwise>
38 <xsl:value-of select="."/>
39 </xsl:otherwise>
40 </xsl:choose>
41 </xsl:template>
43 <!-- p: Indicate a paragraph of text -->
44 <xsl:template match="//p">
45 <DIV TYPE="paragraph"><xsl:apply-templates/></DIV>
46 </xsl:template>
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>
51 </xsl:template>
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>
58 </xsl:template>
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/>
65 </xsl:template>
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">
71 <xsl:choose>
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>
76 </xsl:choose>
77 </xsl:variable>
79 <xsl:element name="{$tag}">
80 <!-- Create the right attribute to go with element $tag. -->
82 <xsl:choose>
83 <!-- gender:
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>
88 </xsl:when>
89 <xsl:when test="name($a[1])='gender' and $a[1]='female'">
90 <xsl:attribute name="GENDER">female1</xsl:attribute>
91 </xsl:when>
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>
95 </xsl:when>
97 <!-- age:
98 The age of the voice.
99 Positive integer values are supported. -->
100 <xsl:when test="name($a[1])='age' and number($a[1]) &lt; 10">
101 <xsl:attribute name="AGE">child</xsl:attribute>
102 </xsl:when>
103 <xsl:when test="name($a[1])='age' and number($a[1]) &lt; 20">
104 <xsl:attribute name="AGE">teen</xsl:attribute>
105 </xsl:when>
106 <xsl:when test="name($a[1])='age' and number($a[1]) &lt; 30">
107 <xsl:attribute name="AGE">younger</xsl:attribute>
108 </xsl:when>
109 <xsl:when test="name($a[1])='age' and number($a[1]) &lt; 50">
110 <xsl:attribute name="AGE">middle</xsl:attribute>
111 </xsl:when>
112 <xsl:when test="name($a[1])='age'">
113 <xsl:attribute name="AGE">older</xsl:attribute>
114 </xsl:when>
116 <!-- name:
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>
120 </xsl:when>
121 </xsl:choose>
123 <!-- Recursively call ourself. -->
124 <xsl:choose>
125 <xsl:when test="$a[2]">
126 <xsl:call-template name="voice"><xsl:with-param name="a" select="$a[position()>1]" /></xsl:call-template>
127 </xsl:when>
128 <xsl:otherwise>
129 <xsl:apply-templates/>
130 </xsl:otherwise>
131 </xsl:choose>
133 </xsl:element>
134 </xsl:template>
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" />
140 </xsl:call-template>
141 </xsl:template>
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">
147 <xsl:choose>
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>
153 </xsl:choose>
154 </xsl:variable>
156 <xsl:element name="{$tag}">
157 <!-- Create the right attribute to go with element $tag. -->
159 <xsl:choose>
160 <!-- pitch:
161 The pitch with which the text is spoken.
162 Values such as x-high, high, low, etc. and percentages (+ or -)
163 are supported. -->
164 <xsl:when test="name($a[1])='pitch' and $a[1]='x-high'">
165 <xsl:attribute name="BASE">70%</xsl:attribute>
166 </xsl:when>
167 <xsl:when test="name($a[1])='pitch' and $a[1]='high'">
168 <xsl:attribute name="BASE">40%</xsl:attribute>
169 </xsl:when>
170 <xsl:when test="name($a[1])='pitch' and $a[1]='medium'">
171 <xsl:attribute name="BASE">0%</xsl:attribute>
172 </xsl:when>
173 <xsl:when test="name($a[1])='pitch' and $a[1]='low'">
174 <xsl:attribute name="BASE">-40%</xsl:attribute>
175 </xsl:when>
176 <xsl:when test="name($a[1])='pitch' and $a[1]='x-low'">
177 <xsl:attribute name="BASE">-70%</xsl:attribute>
178 </xsl:when>
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>
182 </xsl:when>
184 <!-- rate:
185 The speed at which the text is spoken.
186 Values such as x-fast, fast, slow, etc. and percentages (+ or -)
187 are supported. -->
188 <xsl:when test="name($a[1])='rate' and $a[1]='x-fast'">
189 <xsl:attribute name="SPEED">70%</xsl:attribute>
190 </xsl:when>
191 <xsl:when test="name($a[1])='rate' and $a[1]='fast'">
192 <xsl:attribute name="SPEED">40%</xsl:attribute>
193 </xsl:when>
194 <xsl:when test="name($a[1])='rate' and $a[1]='medium'">
195 <xsl:attribute name="SPEED">0%</xsl:attribute>
196 </xsl:when>
197 <xsl:when test="name($a[1])='rate' and $a[1]='slow'">
198 <xsl:attribute name="SPEED">-40%</xsl:attribute>
199 </xsl:when>
200 <xsl:when test="name($a[1])='rate' and $a[1]='x-slow'">
201 <xsl:attribute name="SPEED">-70%</xsl:attribute>
202 </xsl:when>
203 <xsl:when test="name($a[1])='rate'">
204 <xsl:attribute name="SPEED"><xsl:value-of select=" $a[1]"/></xsl:attribute>
205 </xsl:when>
207 <!-- volume:
208 The volume at which the text is spoken.
209 Values such as x-loud, loud, quiet, etc. and percentages (+ or -)
210 are supported. -->
211 <xsl:when test="name($a[1])='volume' and $a[1]='x-loud'">
212 <xsl:attribute name="LEVEL">70%</xsl:attribute>
213 </xsl:when>
214 <xsl:when test="name($a[1])='volume' and $a[1]='loud'">
215 <xsl:attribute name="LEVEL">50%</xsl:attribute>
216 </xsl:when>
217 <xsl:when test="name($a[1])='volume' and $a[1]='medium'">
218 <xsl:attribute name="LEVEL">0%</xsl:attribute>
219 </xsl:when>
220 <xsl:when test="name($a[1])='volume' and $a[1]='soft'">
221 <xsl:attribute name="LEVEL">-50%</xsl:attribute>
222 </xsl:when>
223 <xsl:when test="name($a[1])='volume' and $a[1]='x-soft'">
224 <xsl:attribute name="LEVEL">-70%</xsl:attribute>
225 </xsl:when>
226 <xsl:when test="name($a[1])='volume' and $a[1]='silent'">
227 <xsl:attribute name="LEVEL">-100%</xsl:attribute>
228 </xsl:when>
229 <xsl:when test="name($a[1])='volume'">
230 <xsl:attribute name="LEVEL"><xsl:value-of select=" $a[1]"/></xsl:attribute>
231 </xsl:when>
233 <!-- range:
234 The volume at which the text is spoken.
235 Values such as x-high, high, medium, low, x-low, etc. and percentages (+ or -)
236 are supported. -->
237 <xsl:when test="name($a[1])='range' and $a[1]='x-high'">
238 <xsl:attribute name="RANGE">70%</xsl:attribute>
239 </xsl:when>
240 <xsl:when test="name($a[1])='range' and $a[1]='high'">
241 <xsl:attribute name="RANGE">40%</xsl:attribute>
242 </xsl:when>
243 <xsl:when test="name($a[1])='range' and $a[1]='medium'">
244 <xsl:attribute name="RANGE">0%</xsl:attribute>
245 </xsl:when>
246 <xsl:when test="name($a[1])='range' and $a[1]='low'">
247 <xsl:attribute name="RANGE">-40%</xsl:attribute>
248 </xsl:when>
249 <xsl:when test="name($a[1])='range' and $a[1]='x-low'">
250 <xsl:attribute name="RANGE">-70%</xsl:attribute>
251 </xsl:when>
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>
255 </xsl:when>
257 </xsl:choose>
259 <!-- Recursively call ourself. -->
260 <xsl:choose>
261 <xsl:when test="$a[2]">
262 <xsl:call-template name="prosody"><xsl:with-param name="a" select="$a[position()>1]" /></xsl:call-template>
263 </xsl:when>
264 <xsl:otherwise>
265 <xsl:apply-templates/>
266 </xsl:otherwise>
267 </xsl:choose>
268 </xsl:element>
269 </xsl:template>
271 </xsl:stylesheet>