-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.html
More file actions
311 lines (253 loc) · 9.56 KB
/
Copy pathpopup.html
File metadata and controls
311 lines (253 loc) · 9.56 KB
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
311
<!DOCTYPE html>
<html lang="en, nl">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TTS - NL, EN</title>
<link rel="shortcut icon" href="img/W-tts.png">
</head>
<body>
<style>
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
padding: 1em;
width: 400px;
height: 600px;
display: grid;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;
color: #ffffffb6;
background-image: linear-gradient(45deg, #4159d0, #c850c0, #ffcd70);
font: 1.25rem/1 'Poppins', sans-serif;
}
input {
margin-left: 1em;
}
.wrapper {
display: grid;
gap: 20px;
width: 600px;
max-width: calc(100vw - 40px);
padding: 30px;
border-radius: 10px;
background-color: #0003;
}
#text {
display: block;
height: 100px;
padding: 20px;
border: none;
font-size: inherit;
font-family: inherit;
resize: vertical;
}
.properties {
display: grid;
grid-template-columns: max-content minmax(0, auto) 40px;
gap: 20px;
padding: 20px;
background-color: #0003;
}
#voice {
font-size: 0.875rem;
font-family: inherit;
}
#speak {
padding: 10px;
border: 1px solid #fff;
color: #fff;
background-color: #0009;
font-size: inherit;
font-family: inherit;
cursor: pointer;
appearance: none;
}
#text {
background-color: rgba(0, 0, 0, 0.215);
}
#button {
max-width: 60%;
}
img {
position: absolute;
left: 225px;
top: 15px;
}
</style>
<script>
window.console = window.console || function (t) { };
</script>
<label>
<a href="https://github.com/OctosTechLab/TTS-NL-EN" target="_blank"><img src="img/W-tts.png" alt="TTS" width="150" height="150"></img></a>
<input type="range" min="0" max="100" value="0" with="100"></input>
</label>
<div class="wrapper">
<script src="/popup.js"></script>
<label for="text">Text to speak: <button id="speak" class="floating-button myButton" href="#"><a>
<i class="fa fa-play"></i>
<i class="fa fa-pause-circle-o"></i>
</a></button></label>
<textarea id="text">Welcome to TTS with the top Sneijder you can change the color of the website.</textarea>
<div class="properties">
<label for="voice">Voice:</label>
<select id="voice">
<option value="urn:moz-tts:sapi:Microsoft Zira - English (United States)?en-US">English (United States) - Microsoft Zira</option>
<option value="urn:moz-tts:sapi:Microsoft Frank - Dutch (Netherlands)?nl-NL">Dutch (Netherlands) - Microsoft Frank</option>
</select>
<div></div>
<label for="pitch">Pitch:</label>
<input id="pitch" type="range" min="0.1" max="2" step="0.1" value="1">
<output for="pitch">1</output>
<label for="rate">Rate:</label>
<input id="rate" type="range" min="0.1" max="1.3" step="0.1" value="1">
<output for="rate">1.3</output>
<label for="volume">Volume:</label>
<input id="volume" type="range" min="0" max="1" step="0.1" value="1">
<output for="volume">1</output>
</div>
</div>
<script src="https://cpwebassets.codepen.io/assets/common/stopExecutionOnTimeout-2c7831bb44f98c1391d6a4ffda0e1fd302503391ca806e7fcc7b9b87197aec26.js"></script>
<script id="rendered-js">
// grab the UI elements to work with
const textEl = document.getElementById('text');
const voiceInEl = document.getElementById('voice');
const pitchInEl = document.getElementById('pitch');
const rateInEl = document.getElementById('rate');
const volumeInEl = document.getElementById('volume');
const pitchOutEl = document.querySelector('output[for="pitch"]');
const rateOutEl = document.querySelector('output[for="rate"]');
const volumeOutEl = document.querySelector('output[for="volume"]');
const speakEl = document.getElementById('speak');
// add UI event handlers
pitchInEl.addEventListener('change', updateOutputs);
rateInEl.addEventListener('change', updateOutputs);
volumeInEl.addEventListener('change', updateOutputs);
speakEl.addEventListener('click', speakText);
// update voices immediately and whenever they are loaded
updateVoices();
window.speechSynthesis.onvoiceschanged = updateVoices;
function updateOutputs() {
// display current values of all range inputs
pitchOutEl.textContent = pitchInEl.value;
rateOutEl.textContent = rateInEl.value;
volumeOutEl.textContent = volumeInEl.value;
}
function updateVoices() {
// add an option for each available voice that isn't already added
window.speechSynthesis.getVoices().forEach(voice => {
const isAlreadyAdded = [...voiceInEl.options].some(option => option.value === voice.voiceURI);
if (!isAlreadyAdded) {
const option = new Option(voice.name, voice.voiceURI, voice.default, voice.default);
voiceInEl.add(option);
}
});
}
function speakText() {
// stop any speaking in progress
window.speechSynthesis.cancel();
// create new utterance with all the properties
const text = textEl.value;
const utterance = new SpeechSynthesisUtterance(text);
utterance.voice = window.speechSynthesis.getVoices().find(voice => voice.voiceURI === voiceInEl.value);
utterance.pitch = pitchInEl.value;
utterance.rate = rateInEl.value;
utterance.volume = volumeInEl.value;
// speak that utterance
window.speechSynthesis.speak(utterance);
}
//# sourceURL=pen.js
</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<style>
.floating-button {
position: relative;
top: 23px;
justify-content: center;
align-items: center;
text-align: center;
font-size: 32px;
width: 2em;
height: 2em;
border-radius: 50%;
/* background: darken($san-juan, 10); */
border: 0.1em solid;
color: #fff;
text-decoration: none;
}
.fa {
position: relative;
top: -4px;
}
.floating-button>.fa {
font-size: 1em;
line-height: 2em;
animation: 0.4s toggle;
}
.floating-button>.hidden {
display: none;
}
@keyframes toggle {
0% {
font-size: 0em;
opacity: 0;
}
70% {
font-size: 1.3em;
opacity: 1;
}
100% {
font-size: 1em;
}
}
</style>
<script src="https://cpwebassets.codepen.io/assets/common/stopExecutionOnTimeout-2c7831bb44f98c1391d6a4ffda0e1fd302503391ca806e7fcc7b9b87197aec26.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script id="rendered-js">
$('.floating-button').on('click', function (event) {
event.preventDefault();
$(this).children(':first').toggleClass('hidden');
$(this).children(':last').toggleClass('hidden');
});
//# sourceURL=pen.js
</script>
<style>
/* Basisstijl voor de knop */
.myButton {
background-color: #007bff;
color: #fff;
padding: 10px 20px;
border: none;
cursor: pointer;
transition: background-color 0.3s ease-in-out;
}
/* Hover-effect voor de knop */
.myButton:hover {
background-color: #0056b3;
}
/* Klik-effect voor de knop */
.myButton:active {
transform: scale(0.95);
}
</style>
<script>
// JavaScript om de klik-effect te activeren
var buttons = document.getElementsByClassName('myButton');
for (var i = 0; i < buttons.length; i++) {
buttons[i].addEventListener('mousedown', function () {
this.style.transform = 'scale(0.95)';
});
buttons[i].addEventListener('mouseup', function () {
this.style.transform = 'scale(1)';
});
}
</script>
</body>
</html>