E57C Cleaned up code with final changes! · alia11y/SSMLinHTMLproposal@72d957d · GitHub
[go: up one dir, main page]

Skip to content

Commit 72d957d

Browse files
committed
Cleaned up code with final changes!
1 parent 09c11b7 commit 72d957d

File tree

3 files changed

+5
-173
lines changed

3 files changed

+5
-173
lines changed

index.html

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
<meta charset="utf-8">
99
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
1010
<meta name="viewport" content="width=device-width">
11-
<title>ETS SSML Markup Tester v2.2</title>
11+
<title>ETS SSML Markup Tester v2.4</title>
1212
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
1313
<link rel="stylesheet" href="ssml.css" >
1414

1515
</head>
1616

1717
<body>
1818
<div class="container">
19-
<h1>ETS SSML Markup Tester v2.3 (07/20/2017)</h1>
19+
<h1>ETS SSML Markup Tester v2.4 (07/20/2017)</h1>
2020
<p><span id="instructions-section">Enter text</span> marked up with either SSML elements or span
2121
elements using data attributes data-ssml and data-ssmlval (only a limited number of SSML tags supported). If using data attributes,
2222
select the data attributes checkbox. If the selected synthesizer supports SSML, you
@@ -27,10 +27,7 @@ <h1>ETS SSML Markup Tester v2.3 (07/20/2017)</h1>
2727

2828
</div>
2929
<div >
30-
<button onclick="example2()" class="btn btn-primary btn-sm">SSML Kitchen Sink Example</button>
31-
<button onclick="example3()" class="btn btn-primary btn-sm">Simple Data Attribute Example</button>
32-
<button onclick="example4()" class="btn btn-primary btn-sm">Data Attribute Kitchen Sink Example</button>
33-
<button onclick="example5()" class="btn btn-primary btn-sm">Date and Time Format</button>
30+
3431
<button onclick="example6()" class="btn btn-primary btn-sm">JSON To SSML</button>
3532

3633
</div>
@@ -98,28 +95,10 @@ <h1>ETS SSML Markup Tester v2.3 (07/20/2017)</h1>
9895
var browserInfo = getBrowserInfo();
9996
document.getElementById("platform").innerHTML = "User Agent: " + browserInfo + " on "+ navigator.platform;
10097

101-
function example2()
102-
{document.getElementById('AuthoredText').value="I am now <prosody rate='x-fast'>speaking very fast</prosody> and now at a normal rate. <prosody pitch='x-low'>This is half-pitch</prosody>"+"This is <emphasis level='strong'>stronger</emphasis> than the rest. My zip code is <say-as interpret-as='characters'>18648</say-as> and <say-as interpret-as='ordinal'>18648</say-as> is a large number.";
103-
document.getElementById('chkDataAttr').checked=true;
104-
}
105-
function example3()
106-
{document.getElementById('AuthoredText').value="The pool is 10 <span data-ssml='sub' data-ssmlval='meters'>m</span> in length.";
107-
document.getElementById('chkDataAttr').checked=true;
108-
}
109-
function example4()
110-
{document.getElementById('AuthoredText').value="I am now <span data-ssml='prosody' data-ssmlval='fast'>speaking very fast</span> and now at a normal rate. My zip code is <span data-ssml='say-as' data-ssmlval='characters'>18648</span> and <span data-ssml='say-as' data-ssmlval='ordinal'>18648</span> is a large number.";
111-
document.getElementById('chkDataAttr').checked=true;
112-
113-
}
114-
115-
function example5()
116-
{document.getElementById('AuthoredText').value="Today <span data-ssml='say-as' data-ssmlval='date' data-format='dmy'>04/07/2017</span> at <span data-ssml='say-as' data-ssmlval='time' data-format='hms24'>00:00:00</span> I am going to turn 21. and <span data-ssml='say-as' data-ssmlval='time' data-format='hms24'>19:21:30</span>";
117-
document.getElementById('chkDataAttr').checked=true;
11898

119-
}
12099

121100
function example6()
122-
{document.getElementById('AuthoredText').value="I am now <span data-ssml='{\"prosody\" : {\"rate\":\"x-fast\"}}'>speaking very fast</span> and now at a normal rate. I am speaking <span data-ssml='{\"prosody\" : {\"rate\":\"slow\"}}'>very slow</span>. You need to make it <span data-ssml='{\"emphasis\" : {\"level\":\"strong\"}}'>very strong should sound different</span>, very strong and now normal rate. Here <span data-ssml='{\"say-as\" : {\"interpret-as\":\"cardinal\"}}'>12345</span> is large number.";
101+
{document.getElementById('AuthoredText').value="I am now <span data-ssml='{\"prosody\" : {\"rate\":\"x-fast\"}}'>speaking very fast</span> and now at a normal rate. I am speaking <span data-ssml='{\"prosody\" : {\"rate\":\"slow\"}}'>very slow</span>. You need to make it <span data-ssml='{\"emphasis\" : {\"level\":\"strong\"}}'>very strong should sound different</span>, very strong and now normal rate. Here <span data-ssml='{\"say-as\" : {\"interpret-as\":\"cardinal\"}}'>12345</span> is large number.";
123102
document.getElementById('chkJSONAttr').checked=true;
124103

125104
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ attributes to the Apple speech markup and then sent to Web Speech.
1212

1313
This code is made available "as is" for demonstration purposes, and not intended as a specific proposed method of implementing SSML support in HTML.
1414

15-
A live version is available at [http://www.ets-research.org/ia11ylab/ssmltool/ia/index.html]
15+
A live version is available at [http://www.ets-research.org/ia11ylab/ssmltool/]
1616

1717
*Note* that you will need to have an SSML aware syntehsizer available on Windows, or be running on MacOS.
1818

script-mac.js

Lines changed: 0 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -65,153 +65,6 @@ function produceSpeech(){
6565
var bDataAttr=document.getElementById('chkDataAttr').checked;
6666

6767

68-
if (bDataAttr) {
69-
var s2Parse;
70-
s2Parse=workstring;
71-
var el=document.getElementById('pstruct');
72-
el.innerHTML=s2Parse;
73-
var spans=el.getElementsByTagName("span");
74-
75-
/*************************************************/
76-
while (el.getElementsByTagName('span').length>0)
77-
{
78-
var es=spans[0];
79-
80-
var ssmltag=es.getAttribute('data-ssml');
81-
var ssmlvalue=es.getAttribute('data-ssmlval');
82-
var inText=es.innerHTML;
83-
var isMac=navigator.platform;
84-
/********** Mac Specific ************/
85-
if (isMac.indexOf("Mac")>=0)
86-
{
87-
88-
var preText="";
89-
var postText="";
90-
var ssmlnode=document.createElement('span');
91-
switch (ssmltag) {
92-
case 'sub':
93-
94-
95-
inText=ssmlvalue;
96-
break;
97-
case 'say-as':
98-
switch (ssmlvalue) {
99-
case 'characters':
100-
preText="[[char LTRL]]";
101-
postText="[[char NORM]]";
102-
break;
103-
case 'ordinal':
104-
preText="[[nmbr NORM]]";
105-
postText="[[nmbr NORM]]";
106-
break;
107-
case 'cardinal':
108-
preText="[[nmbr NORM]]";
109-
postText="[[nmbr NORM]]";
110-
break;
111-
case 'date':
112-
preText="[[Day][/][Month][/][Year]]";
113-
postText="[[Day][/][Month][/][Year]]";
114-
break;
115-
case 'time':
116-
preText="[[hour][:][minute]([:][second]]";
117-
postText="[[hour][:][minute]([:][second]]";
118-
break;
119-
}
120-
break;
121-
case 'break':
122-
switch (ssmlvalue) {
123-
case 'weak':
124-
preText="[[slnc 250]]";
125-
postText="[[slnc 0]]";
126-
break;
127-
case 'medium':
128-
preText="[[slnc 500]]";
129-
postText="[[slnc 0]]";
130-
break;
131-
case 'strong':
132-
preText="[[slnc 1000]]";
133-
postText="[[slnc 0]]";
134-
break;
135-
}
136-
break;
137-
case 'emphasis':
138-
switch (ssmlvalue) {
139-
case 'strong':
140-
preText="[[emph +]]";
141-
postText="[[rset 0]]";
142-
break;
143-
case 'moderate':
144-
preText="[[emph +; emph +]]";
145-
postText="[[rset 0]]";
146-
break;
147-
case 'reduced':
148-
preText="[[emph -]]";
149-
postText="[[rset 0]]";
150-
break;
151-
}
152-
break;
153-
case 'prosody':
154-
switch (ssmlvalue) {
155-
case 'fast':
156-
preText="[[rate 300]]";
157-
postText="[[rset 0]]";
158-
break;
159-
case 'slow':
160-
preText="[[rate 75]]";
161-
postText="[[rset 0]]";
162-
break;
163-
}
164-
break;
165-
166-
case 'ref':
167-
inText=ssmlvalue;
168-
break;
169-
case 'src':
170-
inText=ssmlvalue;
171-
break;
172-
173-
174-
175-
176-
}
177-
var ssmlcontent=document.createTextNode(preText + inText + postText);
178-
var parentDiv=es.parentNode;
179-
parentDiv.replaceChild(ssmlcontent, es);
180-
181-
}
182-
else
183-
{
184-
var ssmlnode=document.createElement(ssmltag);
185-
var ssmlcontent=document.createTextNode(inText);
186-
ssmlnode.appendChild(ssmlcontent);
187-
switch (ssmltag) {
188-
case 'sub':
189-
ssmlnode.setAttribute('alias',ssmlvalue);
190-
break;
191-
case 'say-as':
192-
ssmlnode.setAttribute('interpret-as',ssmlvalue);
193-
break;
194-
case 'break':
195-
ssmlnode.setAttribute('strength',ssmlvalue);
196-
break;
197-
case 'emphasis':
198-
ssmlnode.setAttribute('level',ssmlvalue);
199-
break;
200-
case 'phoneme':
201-
ssmlnode.setAttribute('alphabet',ssmlvalue);
202-
break;
203-
case 'prosody':
204-
ssmlnode.setAttribute('rate',ssmlvalue);
205-
break;
206-
}
207-
var parentDiv=es.parentNode;
208-
parentDiv.replaceChild(ssmlnode, es);
209-
}
210-
211-
}
212-
workstring=parentDiv.innerHTML;
213-
}
214-
21568
var msSpeakTag='<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" ' +
21669
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '+
21770
'xsi:schemaLocation="http://www.w3.org/2001/10/synthesis '+

0 commit comments

Comments
 (0)
0