-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtextreader.html
366 lines (357 loc) · 20.2 KB
/
textreader.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Text Reader using Google Cloud Text-to-speech</title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.slim.min.js"></script>
<script src="audiobuffer-to-wav.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<style type="text/css">
#t {
height: 300px;
}
</style>
<script src="process.js"></script>
</head>
<body>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column mt-5 mb-3">
<h1>Text Reader using Google Cloud Text-to-speech</h1>
</div>
</div>
<div class="row">
<div class="bg-light col">
<form class="mt-3 p-3" id="mainform">
<div class="form-group row clearfix">
<div class="col-sm-auto">
<label for="voice" class="col-form-label">Default voice</label></div>
<div class="col"><select id="voice" class="custom-select">
<optgroup label="US English" id="en_US">
</optgroup>
<optgroup label="British English" id="en_GB">
</optgroup>
<optgroup label="Mandarin Chinese" id="zh_CN">
</optgroup>
</select></div>
<div class="col-sm-auto"> <label for="speakingrate" class="col-form-label">Default rate</label></div>
<div id="speakingrate" class="form-inline col-auto"><input type="range" id="speed"
class="range custom-range col p-0" min="0.25" max="4.0" step="0.01"
value="1"> <input type="number" min="0.25" max="4.0" step="0.01" id="speedtxt"
value="1" class="rangetxt form-control col-4"> </div>
</div>
<div class="form-group row">
<div class="col-auto"><button id="insertAudio" class="btn btn-outline-primary btn-sm"
data-toggle="modal" data-target="#insertaudiofiledlg">Insert audio file</button> <button
id="supplyMissingAudio" style="display: none;" data-toggle="modal"
data-target="#missingaudiodlg">Supply
missing audio files</button> <button id="insertPause" class="btn btn-outline-primary btn-sm"
data-toggle="modal" data-target="#insertpausedlg">Insert
Pause</button>
<div id="showOnSelect"><div class="dropdown d-inline d-md-none">
<button class="btn btn-outline-secondary dropdown-toggle btn-sm" type="button" id="showOnSelectButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
More
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" data-id="insertRepeat">Insert repeat</a>
<a class="dropdown-item" href="#" data-id="changevoice">Change voice</a>
<a class="dropdown-item" href="#" data-id="dlgmaker">Dialog Maker</a>
<a class="dropdown-item" href="#" data-id="insertEmph">Insert emphasis</a>
<a class="dropdown-item" href="#" data-id="insertProsody">Insert prosody</a>
</div>
</div><div class="d-none d-md-inline"><button id="insertRepeat" class="btn btn-outline-secondary btn-sm">Insert
repeat</button>
<button id="changevoice" class="btn btn-outline-secondary btn-sm">Change
voice</button>
<button id="dlgmaker" class="btn btn-outline-secondary btn-sm">Dialog Maker</button> <button
id="insertEmph" class="btn btn-outline-secondary btn-sm">Insert emphasis</button> <button
id="insertProsody" class="btn btn-outline-secondary btn-sm">Insert prosody</button></div></div>
</div>
</div>
<div class="form-group row">
<div class="col-md-12"><textarea id="t" autofocus spellcheck="false"
placeholder="Enter text you wish spoken here." class="form-control"></textarea></div>
</div>
<div class="form-group row">
<div class="col-auto"><button id="sub" class="btn btn-primary">Speak it!</button> <button id="saveit"
class="btn btn-secondary" data-toggle="modal" data-target="#inputfilenamedlg">Save audio to file</button></div>
</div>
</form></div></div>
<div class="row">
<div class="col bg-info align-middle py-3">
<p class="text-center text-light">Made by <a href="https://github.com/godspirit00" target="_blank"
class="text-light">@godspirit00</a>. Powered by <a
href="https://cloud.google.com/text-to-speech" target="_blank" class="text-light">Google Cloud
Text to speech</a>.</p>
</div>
</div>
</div>
<br>
<div id="choosevoicedlg" class="modal fade" role="dialog" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Change voice</h5> <button type="button" class="close" data-dismiss="modal">
</button>
</div>
<div class="modal-body">
<p>Choose a voice.</p>
<form>
<div class="form-group row">
<div class="form-group col-sm-2">Voice:</div>
<div id="dlgvoicelist0" class="form-group col"></div>
</div>
<div class="form-group row">
<div class="form-group col-sm-2">Rate:</div>
<div id="dlgvoicerate0" class="form-group col"></div>
</div>
</form>
</div>
<div class="modal-footer"><button id="dlgok0" class="btn btn-primary" data-dismiss="modal">OK</button>
<button id="dlgcancel0" class="btn btn-secondary" data-dismiss="modal">Cancel</button></div>
</div>
</div>
</div>
<div id="dlgmakerdlg" class="modal fade" role="dialog" data-backdrop="static">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Dialog Maker</h5><button type="button" class="close" data-dismiss="modal">
</button>
</div>
<div class="modal-body">
<p>Choose a voice for each character.</p>
<form>
<!-- <div class="form-group row dlgchar">
<div class="form-group col-sm-2 charname"></div>
<div class="form-group col dlgvoicelist1"></div>
<div class="form-group col dlgvoicerate1"></div>
</div>
-->
</form>
</div>
<div class="modal-footer"><button id="dlgok1" class="btn btn-primary" data-dismiss="modal">OK</button>
<button id="dlgcancel1" class="btn btn-secondary" data-dismiss="modal">Cancel</button></div>
</div>
</div>
</div>
<div id="emphasisdlg" class="modal fade" role="dialog" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Insert emphasis</h5> <button type="button" class="close"
data-dismiss="modal">
</button>
</div>
<div class="modal-body">
Choose an emphasis level: <select id="emphlvl" class="custom-select">
<option value="strong">Strong</option>
<option value="moderate">Moderate</option>
<option value="none" selected>None</option>
<option value="reduced">Reduced</option>
</select> </div>
<div class="modal-footer"><button id="dlgok2" class="btn btn-primary" data-dismiss="modal">OK</button>
<button id="dlgcancel2" class="btn btn-secondary" data-dismiss="modal">Cancel</button></div>
</div>
</div>
</div>
<div id="prosodydlg" class="modal fade" role="dialog" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Insert prosody</h5> <button type="button" class="close"
data-dismiss="modal">
</button>
</div>
<div class="modal-body">
<p> Set prosody:</p>
<div class="row mb-2">
<div class="col-2">Pitch</div>
<div class="col form-inline"><input type="range" id="pitch" min="-8" max="8" value="0"
class="range custom-range col-4 p-0"> <input type="number"
id="pitchtxt" max="8" min="-8" step="1" class="rangetxt form-control col-3"
value="0"> semitone</div>
</div>
<div class="row">
<div class="col-2">Rate</div>
<div class="col form-inline"> <input type="range" id="rate" min="0" max="500" value="100"
step="10" class="range custom-range col-4 p-0"> <input type="number"
id="ratetxt" min="0" max="500" step="10" class="rangetxt form-control col-3"
value="100"> %</div>
</div>
</div>
<div class="modal-footer"><button id="dlgok3" class="btn btn-primary" data-dismiss="modal">OK</button>
<button id="dlgcancel3" class="btn btn-secondary" data-dismiss="modal">Cancel</button></div>
</div>
</div>
</div>
<div id="insertaudiofiledlg" class="modal fade" role="dialog" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Insert audio file</h5> <button type="button" class="close"
data-dismiss="modal">
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<div id="audiolist" class="form-group col custom-control custom-radio">
<div class="filebrowser"><input type="radio" name="a" id="audios-1" value="-1" checked
class="custom-control-input audios"> <label for="audios-1" class="custom-control-label">
Pick a file:</label>
<input type="file" id="audiofile" accept="audio/*"></div>
</div>
<div class="form-group col custom-control custom-radio"><input type="radio" name="a" id="audios-2" value="-2"
class="custom-control-input audios"><label class="custom-control-label"
for="audios-2"><input type="url" id="audiourl"
placeholder="Enter URL to the audio file. e.g.: http://example.com/a.mp3"
size="80" class="form-control"> </label><audio id="previewer"
style="display: none;"></audio>
</div>
</div>
</form>
</div>
<div class="modal-footer"><button id="dlgok5" class="btn btn-primary" data-dismiss="modal">OK</button>
<button id="dlgcancel5" class="btn btn-secondary" data-dismiss="modal">Cancel</button></div>
</div>
</div>
</div>
<div id="missingaudiodlg" class="modal fade" role="dialog" data-backdrop="static">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Missing audio files</h5> <button type="button" class="close"
data-dismiss="modal">
</button>
</div>
<div class="modal-body">
<p>Some audio files are missing. Due to security reasons, your browser won't allow us to read files
directly from your device. This happens when you load a previously composed script.</p>
<p>To continue with the audio files you have inserted, please supply the missing audio files.</p>
<p>To skip this step, please manually remove the <code><audio></code> tags with the
corresponding <code>id</code>. </p>
<div class="table-responsive">
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">#</th>
<th scope="col">Audio file name</th>
<th scope="col">Browse</th>
</tr>
</thead>
<tbody id="missingaudiolist">
</tbody>
</table>
</div>
<p>After you finish, please hit <mark>Speak it!</mark> again.</p>
</div>
<div class="modal-footer"><button id="dlgok6" class="btn btn-primary" data-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="msgbox" tabindex="-1" role="dialog" aria-labelledby="msgbox" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="msgboxTitle">Attention</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="msgboxBody">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" data-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="insertpausedlg" tabindex="-1" role="dialog" aria-labelledby="insertpause"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Insert Pause</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>How long would you like to pause for?</p>
<div class="input-group mb-3">
<input type="number" class="form-control" placeholder="Pause for how long?" value="2"
id="pausetime">
<div class="input-group-append btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="radio" name="options" id="sec" checked> sec
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="msec"> msec
</label>
</div>
</div>
</div>
<div class="modal-footer">
<button id="dlgok7" class="btn btn-primary" data-dismiss="modal">OK</button>
<button id="dlgcancel7" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="insertrepeatdlg" tabindex="-1" role="dialog" aria-labelledby="insertRepeat"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Insert Repeat</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>How many times would you like to repeat the selected text?</p>
<p><input type="number" class="form-control" placeholder="Repeat how many times?" value="2" min="2"
step="1" id="repeattimes"></p>
</div>
<div class="modal-footer">
<button id="dlgok8" class="btn btn-primary" data-dismiss="modal">OK</button>
<button id="dlgcancel8" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="inputfilenamedlg" tabindex="-1" role="dialog" aria-labelledby="insertRepeat"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Enter a file name</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Please enter a name for the audio file about to be generated.</p>
<div class="form-group row"><div class="col"><input type="text" class="form-control" placeholder="File name" id="filename"></div><label for="filename" class="col-2 col-form-label"><strong>.wav</strong></label>
</div>
</div>
<div class="modal-footer">
<button id="dlgok9" class="btn btn-primary" data-dismiss="modal">OK</button>
<button id="dlgcancel9" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<script src="document.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
</body>
</html>