-
Notifications
You must be signed in to change notification settings - Fork 1
/
translate.html
443 lines (408 loc) · 16.1 KB
/
translate.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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8"/>
<meta content="O Sistema de Reconhecimento de Fala em Tempo Real desenvolvido por Miguel Kallemback transforma a acessibilidade em conteúdo audiovisual, oferecendo transcrição de áudio em tempo real em diversos idiomas. Ideal para profissionais da indústria audiovisual procurando uma solução econômica para tornar seu conteúdo acessível a um público mais amplo." name="description"/>
<meta content="reconhecimento de fala, transcrição de áudio, acessibilidade, conteúdo audiovisual, legendas ao vivo, Miguel Kallemback, multilíngue, tecnologia de reconhecimento de voz" name="keywords"/>
<meta content="Miguel Kallemback" name="author"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400&family=Cousine&family=Montserrat:wght@400&family=Oswald:wght@400&family=Lobster&family=Pacifico&family=Quicksand:wght@500&family=Lato:wght@400&family=Source+Sans+Pro:wght@400&family=Open+Sans:wght@400&family=Zilla+Slab:wght@500&family=Playfair+Display:wght@400&family=Merriweather:wght@400&family=Arvo:wght@400&family=Ubuntu:wght@400&display=swap" rel="stylesheet"/>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
background-color: black;
color: white;
height: 100vh;
margin: 0;
transition: text 0.3s ease;
}
.controls {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
font-family: 'Cousine', monospace;
font-size: 1em;
margin: 0.5em;
padding: 0.5em;
background-color: rgb(51, 51, 51);
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
max-width: 500px;
justify-content: space-between;
}
.controls label,
.controls select,
.controls button,
.controls input {
margin: 0.2em;
}
.controls > div {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.output {
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
background-color: rgba(0, 0, 0, 0);
font-family: 'Cousine', monospace;
font-size: 2.5em;
line-height: 1.1em;
letter-spacing: 0.05em;
padding: 0.5em;
width: 60%;
height: 150px;
overflow-y: auto;
text-align: left !important;
margin: auto;
transition: background-color 0.3s;
resize: none;
overflow: auto;
transition: text 0.3s ease !important;
}
#resetPreferences {
display: inline-block;
padding: 0.5em 1em;
font-size: 1rem;
color: white;
font-family: 'Cousine', monospace;
border: 2px solid #f6df5c;
background-color: transparent;
border-radius: 0.375em;
transition: background-color 0.3s ease;
}
#copyButton {
display: inline-block;
padding: 0.5em 1em;
font-size: 1rem;
color: white;
font-family: 'Cousine', monospace;
border: 2px solid #615cf6;
background-color: transparent;
border-radius: 0.375em;
transition: background-color 0.3s ease;
}
#startButton {
display: inline-block;
padding: 0.5em 1em;
font-size: 1rem;
color: white;
font-family: 'Cousine', monospace;
border: 2px solid #5cf664;
background-color: transparent;
border-radius: 0.375em;
transition: background-color 0.3s ease;
}
#startButton:hover {
background-color: #5cf664;
color: rgb(61, 61, 61);
}
.color-picker,
.font-slider {
display: flex;
align-items: center;
margin: 0.2em;
}
.color-picker label,
.font-slider label {
margin-right: 0.5em;
}
#output {
transition: text 0.3s ease;
color: white;
}
textarea {
overflow: auto;
scrollbar-width: none; /* Para navegadores Firefox */
}
textarea::-webkit-scrollbar {
width: 0px; /* Para navegadores WebKit, Chrome, Safari etc. */
}
.customButton {
display: none;
padding: 0.5em 1em;
font-size: 1rem;
color: white;
font-family: 'Cousine', monospace;
border: 2px solid #f6df5c;
background-color: transparent;
border-radius: 0.375em;
transition: background-color 0.3s ease;
width: 100px; /* Ou o tamanho que você desejar */
}
.subtitle{
transition: 0.3s ease;
}
.custom-dropdown {
font-family: 'Cousine', monospace; /* Tipo de letra */
color: #ffffff; /* Cor do texto */
background-color: #333333; /* Cor de fundo do dropdown */
border: 1px solid #ffffff; /* Cor da borda */
border-radius: 5px; /* Raio da borda */
padding: 5px; /* Espaçamento interno */
outline: none; /* Remove o contorno ao focar */
cursor: pointer; /* Muda o cursor para um ponteiro */
}
.custom-dropdown:hover,
.custom-dropdown:focus {
background-color: #555555; /* Cor de fundo do dropdown quando focado ou quando o mouse passa por cima */
}
.custom-dropdown option {
color: #000000; /* Cor do texto das opções */
background-color: #ffffff; /* Cor de fundo das opções */
}
.custom-dropdown option:hover,
.custom-dropdown option:focus {
background-color: #eeeeee; /* Cor de fundo das opções quando focadas ou quando o mouse passa por cima */
}
.subtitle { transition: all 0.5s ease-in-out; }
.subtitle { text-align: left !important; }
</style>
<title>Reconhecimento de Fala - LiveCap</title>
</head>
<body>
<div class="controls">
<div>
<label for="microphoneList">Escolha um microfone:</label>
<select class="custom-dropdown" id="microphoneList"></select>
</div>
<button id="startButton">Iniciar</button>
<button class="customButton" id="button1">v2</button>
<button class="customButton" id="button2">Manual</button>
<!-- Seletor de Cor de Fundo e Letra -->
<div class="color-picker">
<label for="bgColor">Cor de Fundo: </label>
<input id="bgColor" name="bgColor" type="color" value="#000000"/>
</div>
<div class="color-picker">
<label for="textColor">Cor da Letra: </label>
<input id="textColor" name="textColor" type="color" value="#ffffff"/>
</div>
<!-- Controle Deslizante para a Largura do Output e Tamanho da Fonte -->
<div class="font-slider">
<label for="fontSize">Tamanho da Fonte: </label>
<input id="fontSize" max="100" min="10" name="fontSize" type="range" value="25"/>
</div>
<div class="font-slider">
<label for="outputWidth">Largura do Output: </label>
<input id="outputWidth" max="100" min="20" name="outputWidth" type="range" value="60"/>
</div>
<div>
<label for="fontFamily">Estilo da Fonte: </label>
<select class="custom-dropdown" id="fontFamily">
<option value="'Cousine', monospace">Cousine</option>
<option value="'Roboto', sans-serif">Roboto</option>
<option value="'Montserrat', sans-serif">Montserrat</option>
<option value="'Oswald', sans-serif">Oswald</option>
<option value="'Lobster', cursive">Lobster</option>
<option value="'Pacifico', cursive">Pacifico</option>
<option value="'Quicksand', sans-serif">Quicksand</option>
<option value="'Lato', sans-serif">Lato</option>
<option value="'Source Sans Pro', sans-serif">Source Sans Pro</option>
<option value="'Open Sans', sans-serif">Open Sans</option>
<option value="'Zilla Slab', serif">Zilla Slab</option>
<option value="'Playfair Display', serif">Playfair Display</option>
<option value="'Merriweather', serif">Merriweather</option>
<option value="'Arvo', serif">Arvo</option>
<option value="'Ubuntu', sans-serif">Ubuntu</option>
</select>
</div>
<div>
<label for="uppercaseCheckbox">Todas as Letras Maiúsculas: </label>
<input id="uppercaseCheckbox" name="uppercaseCheckbox" type="checkbox"/>
</div>
<!-- Botão para apagar preferências -->
<button id="copyButton">Copiar Texto</button><button id="resetPreferences">Resetar Preferências</button>
<div id="google_translate_element"></div>
</div>
<div class="output" id="output" readonly=""></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'pt', includedLanguages: 'en,es,fr', layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT}, 'google_translate_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit" type="text/javascript"></script>
<script>
const output = document.getElementById('output');
const microphoneList = document.getElementById('microphoneList');
const startButton = document.getElementById('startButton');
let recognition;
async function getMicrophones() {
try {
await navigator.mediaDevices.getUserMedia({ audio: true });
const devices = await navigator.mediaDevices.enumerateDevices();
const microphones = devices.filter(
(device) => device.kind === 'audioinput',
);
microphones.forEach((mic) => {
const option = document.createElement('option');
option.value = mic.deviceId;
option.textContent =
mic.label || 'Microfone ' + (microphoneList.length + 1);
microphoneList.appendChild(option);
});
} catch (error) {
console.error('Erro ao acessar o microfone: ', error);
}
}
let timeoutId;
function startRecognition() {
// Muda o texto do botão para "Reconhecendo fala"
startButton.textContent = 'Ouvindo';
recognition = new (window.SpeechRecognition ||
window.webkitSpeechRecognition)();
recognition.lang =
new URLSearchParams(window.location.search).get('lang') || 'pt-BR';
recognition.interimResults = true;
let subtitleCount = 0;
let interimBuffer = [];
let timer;
recognition.onresult = (event) => {
for (let i = event.resultIndex; i < event.results.length; i++) {
const transcript = event.results[i][0].transcript;
if (event.results[i].isFinal) {
if (timer) clearTimeout(timer);
interimBuffer = []; // Clear the interim buffer as we have a final result
createSubtitle(transcript);
} else {
interimBuffer.push(transcript);
if (timer) clearTimeout(timer);
timer = setTimeout(() => {
createSubtitle(interimBuffer.join(' '));
interimBuffer = []; // Clear the interim buffer as we have created a subtitle
}, 3000); // 3 seconds timeout for creating a new subtitle from interim results
}
}
};
function createSubtitle(text) {
subtitleCount++;
const subtitleDiv = document.createElement('div');
subtitleDiv.className = 'subtitle';
subtitleDiv.id = 'subtitle' + subtitleCount;
subtitleDiv.textContent = text;
output.appendChild(subtitleDiv);
output.scrollTop = output.scrollHeight;
}
recognition.onerror = (event) => {
console.error(event.error);
};
recognition.onend = () => {
recognition.start();
// Muda o texto do botão de volta para "Iniciar" quando o reconhecimento de fala termina
startButton.textContent = 'Iniciar';
};
recognition.start();
}
startButton.addEventListener('click', startRecognition);
function loadPreferences() {
const bgColor = localStorage.getItem('bgColor');
const textColor = localStorage.getItem('textColor');
const fontSize = localStorage.getItem('fontSize');
const outputWidth = localStorage.getItem('outputWidth');
const fontFamily = localStorage.getItem('fontFamily');
if (fontFamily) {
document.getElementById('output').style.fontFamily = fontFamily;
document.getElementById('fontFamily').value = fontFamily;
}
}
if (bgColor) {
document.body.style.backgroundColor = bgColor;
document.getElementById('bgColor').value = bgColor;
}
if (textColor) {
document.body.style.color = textColor;
document.getElementById('textColor').value = textColor;
}
if (fontSize) {
document.getElementById('output').style.fontSize = fontSize + 'px';
document.getElementById('fontSize').value = fontSize;
}
if (outputWidth) {
document.getElementById('output').style.width = outputWidth + '%';
document.getElementById('outputWidth').value = outputWidth;
}
function resetPreferences() {
if (confirm('Tem certeza de que deseja resetar as preferências?')) {
localStorage.removeItem('bgColor');
localStorage.removeItem('textColor');
localStorage.removeItem('fontSize');
localStorage.removeItem('outputWidth');
localStorage.removeItem('fontFamily');
loadPreferences();
location.reload();
}
}
document
.getElementById('resetPreferences')
.addEventListener('click', resetPreferences);
document
.getElementById('fontFamily')
.addEventListener('change', function () {
document.getElementById('output').style.fontFamily = this.value;
localStorage.setItem('fontFamily', this.value);
});
document.getElementById('bgColor').addEventListener('input', function () {
document.body.style.backgroundColor = this.value;
localStorage.setItem('bgColor', this.value);
});
document
.getElementById('textColor')
.addEventListener('input', function () {
document.body.style.color = this.value;
document.getElementById('output').style.color = this.value; // Corrigido para mudar a cor do texto dentro do textarea
localStorage.setItem('textColor', this.value);
});
document
.getElementById('fontSize')
.addEventListener('input', function () {
document.getElementById('output').style.fontSize = this.value + 'px';
localStorage.setItem('fontSize', this.value);
});
document
.getElementById('outputWidth')
.addEventListener('input', function () {
document.getElementById('output').style.width = this.value + '%';
localStorage.setItem('outputWidth', this.value);
});
document
.getElementById('copyButton')
.addEventListener('click', function () {
output.select();
output.setSelectionRange(0, 99999); // Para dispositivos móveis
document.execCommand('copy');
alert('Texto copiado: ' + output.value);
});
document.getElementById('button1').addEventListener('click', function () {
window.location.href = '/legenda/index2.html'; // Substitua pelo link desejado para o Botão 1
});
document.getElementById('button2').addEventListener('click', function () {
window.open('/legenda/manual-livecap.pdf', '_blank'); // Substituirá pelo link desejado para o Botão 2
});
window.onload = function () {
document
.getElementById('uppercaseCheckbox')
.addEventListener('change', function () {
if (this.checked) {
document.getElementById('output').style.textTransform =
'uppercase';
} else {
document.getElementById('output').style.textTransform = 'none';
}
});
getMicrophones();
loadPreferences();
};
// Function to scroll the textarea to the bottom
function scrollToBottom() {
output.scrollTop = output.scrollHeight;
}
// Adding event listener to scroll the textarea to the bottom on input event
output.addEventListener('input', scrollToBottom);
</script>
</body>
</html>