forked from janantala/speech-synthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
310 lines (248 loc) · 8.32 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>speech-synthesis</title>
<link href='http://fonts.googleapis.com/css?family=Titillium+Web:200,300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<link rel="icon" type="image/png" href="img/logo.png">
<style>
[ng-cloak] { display: none; }
html, body {
font-family: 'Titillium Web', sans-serif;
padding: 0;
margin: 0;
text-align: center;
height: 100%;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
header, footer {
background: rgb(229,42,58);
padding: 10px 0;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
}
.div {
position: relative;
padding-bottom: 150px;
}
a {
color: white;
text-decoration: none;
}
a:hover, a:focus {
text-decoration: underline;
}
.text-center {
text-align: center;
}
.text-left {
text-align: left;
}
.title {
color: white;
font-weight: 100;
}
.subtitle {
padding: 0 10px;
}
.body {
margin: 0 auto;
width: 100%;
max-width: 1000px;
min-height: 600px;
padding: 10px;
}
.ribbon-wrapper {
width: 85px;
height: 88px;
overflow: hidden;
position: absolute;
top: -3px;
right: -3px;
}
.ribbon {
font: bold 15px Sans-Serif;
color: #333;
text-align: center;
text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
position: relative;
padding: 7px 0;
left: -5px;
top: 15px;
width: 120px;
background-color: rgb(229,42,58);
color: white;
}
.love {
display: inline-block;
position: relative;
top: .2em;
font-size: 1.2em;
color: white;
-webkit-transform: scale(.9);
-moz-transform: scale(.9);
transform: scale(.9);
-webkit-animation: love .5s infinite linear alternate-reverse;
-moz-animation: love .5s infinite linear alternate-reverse;
animation: love .5s infinite linear alternate-reverse;
}
@-webkit-keyframes love {
to {-webkit-transform: scale(1.2);}
}
@-moz-keyframes love {
to {-moz-transform: scale(1.2);}
}
@keyframes love {
to {transform: scale(1.2);}
}
.code {
padding: 2px 10px;
background-color: rgb(29,31,33);
color: rgb(175,186,183);
font-family: 'Droid Sans Mono', 'Titillium Web', sans-serif;
font-size: 14px;
}
.code-prompt {
font-weight: bold;
}
.code-vial {
color: rgb(108,143,167);
}
.code-yellow {
color: rgb(230,151,70);
}
.textarea {
width: 100%;
height: 100px;
resize: vertical;
font-family: 'Droid Sans Mono', 'Titillium Web', sans-serif;
font-size: 28px;
line-height: 40px;
}
.range {
width: 100%;
}
</style>
</head>
<body class="container" ng-app="adaptiveApp">
<div ng-controller="AdaptiveCtrl" class="div">
<header>
<h1 class="text-center title">speech-synthesis</h1>
<p class="text-center title"><i>Speech Synthesis polyfill</i></p>
<a href="https://github.com/janantala/speech-synthesis"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="Fork me on GitHub"></a>
<p class="code">
<span class="code-prompt code-vial">❯</span> bower install <span class="code-yellow">speech-synthesis</span>
</p>
<p>
<iframe src="http://ghbtns.com/github-btn.html?user=janantala&repo=speech-synthesis&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=janantala&repo=speech-synthesis&type=fork"
allowtransparency="true" frameborder="0" scrolling="0" width="53" height="20"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=janantala&type=follow"
allowtransparency="true" frameborder="0" scrolling="0" width="132" height="20"></iframe>
</p>
</header>
<div class="body">
<h3>Load dependecies:</h3>
<p class="code code-html">
<span><script src="bower_components/speech-synthesis/polyfill.min.js"></script></span>
</p>
<h3>Usage:</h3>
<p class="code code-html text-left">
<span class="code-yellow">// Initialize polyfill</span><br>
<span class="">var fallbackSpeechSynthesis = window.getSpeechSynthesis();</span><br>
<span class="">var fallbackSpeechSynthesisUtterance = window.getSpeechSynthesisUtterance();</span><br>
<br>
<span class="">var u = new fallbackSpeechSynthesisUtterance('Hello World');</span><br>
<span class="">u.lang = 'en-US';</span><br>
<span class="">u.volume = 1.0;</span><br>
<span class="">u.rate = 1.0;</span><br>
<span class="">u.onend = function(event) { console.log('Finished in ' + event.elapsedTime + ' seconds.'); };</span><br>
<span class="">fallbackSpeechSynthesis.speak(u);</span><br>
</p>
<p>
</p>
<p>
<form ng-submit="speak(text, lang, volume, rate)">
<label for="text">Text:</label>
<textarea type="text" id="text" class="textarea" ng-model="text" placeholder="YOUR TEXT TO SPEECH"></textarea>
<p>
<label for="lang">Lang:</label>
<input type="text" ng-model="lang" id="lang">
</p>
<p>
<label for="volume">Volume: {{volume}}</label>
<input type="range" id="volume" class="range" ng-model="volume" min="0" max="1" step="0.1"/>
</p>
<p>
<label for="rate">Rate: {{rate}}</label>
<input type="range" id="rate" class="range" ng-model="rate" min="0.1" max="10" step="0.1"/>
</p>
<button type="submit" >Speek</button>
</form>
</p>
<p>
<button ng-click="pause()">Pause</button>
<button ng-click="resume()">Resume</button>
<button ng-click="cancel()">Cancel queue</button>
</p>
</div>
<footer>
<p class="text-center">Made with <span class="love">♥</span> by <a href="http://janantala.com">Jan Antala</a></p>
<p class="text-center">2014 Licensed under <a href="http://opensource.org/licenses/MIT">MIT</a></p>
</footer>`
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script type="text/javascript" src="src/polyfill.js"></script>
<script type="text/javascript">
// Initialize polyfill
var fallbackSpeechSynthesis = window.speechSynthesisPolyfill;
var fallbackSpeechSynthesisUtterance = window.SpeechSynthesisUtterancePolyfill;
// In real project you want to use this:
// var fallbackSpeechSynthesis = window.getSpeechSynthesis();
// var fallbackSpeechSynthesisUtterance = window.getSpeechSynthesisUtterance();
var fu = new fallbackSpeechSynthesisUtterance('Hello there!');
fallbackSpeechSynthesis.speak(fu);
angular.module('adaptiveApp', []).
controller('AdaptiveCtrl', function ($scope) {
$scope.text = 'YOUR TEXT TO SPEECH';
$scope.lang = 'en-US';
$scope.volume = 1.0; // 0 to 1
$scope.rate = 1.0; // 0.1 to 10
$scope.speak = function(text, lang, volume, rate){
var u = new fallbackSpeechSynthesisUtterance(text);
u.lang = lang;
u.volume = volume;
u.rate = rate;
u.onend = function(event) { console.log('Finished in ' + event.elapsedTime + ' seconds.'); };
u.onpause = function(event) { console.log('Paused in ' + event.elapsedTime + ' seconds.'); };
u.onresume = function(event) { console.log('Resumed in ' + event.elapsedTime + ' seconds.'); };
fallbackSpeechSynthesis.speak(u);
};
$scope.pause = function(){
fallbackSpeechSynthesis.pause();
};
$scope.resume = function(){
fallbackSpeechSynthesis.resume();
};
$scope.cancel = function(){
fallbackSpeechSynthesis.cancel();
};
});
</script>
</body>
</html>