-
Notifications
You must be signed in to change notification settings - Fork 1
/
index2.html
376 lines (346 loc) · 13.1 KB
/
index2.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
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<meta
name="description"
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."
/>
<meta
name="keywords"
content="reconhecimento de fala, transcrição de áudio, acessibilidade, conteúdo audiovisual, legendas ao vivo, Miguel Kallemback, multilíngue, tecnologia de reconhecimento de voz"
/>
<meta name="author" content="Miguel Kallemback" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
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"
/>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
background-color: black;
color: white;
height: 100vh;
margin: 0;
transition: text 0.3s ease;
}
.customButton {
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;
width: 100px; /* Ou o tamanho que você desejar */
}
.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;
border-radius: 0.5em;
width: 60%;
height: 150px;
overflow-y: auto;
text-align: left !important;
margin: auto;
transition: background-color 0.3s;
transition: text 0.3s ease !important;
}
#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;
}
</style>
<title>Reconhecimento de Fala - LiveCap</title>
</head>
<body>
<div class="controls">
<div>
<label for="microphoneList">Escolha um microfone:</label>
<select id="microphoneList"></select>
</div>
<button id="startButton">Iniciar</button>
<button id="button1" class="customButton">v1</button>
<button id="button2" class="customButton">Manual</button>
<!-- Seletor de Cor de Fundo e Letra -->
<div class="color-picker">
<label for="bgColor">Cor de Fundo: </label>
<input type="color" id="bgColor" name="bgColor" value="#000000" />
</div>
<div class="color-picker">
<label for="textColor">Cor da Letra: </label>
<input type="color" id="textColor" name="textColor" 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
type="range"
id="fontSize"
name="fontSize"
min="10"
max="100"
value="25"
/>
</div>
<div class="font-slider">
<label for="outputWidth">Largura do Output: </label>
<input
type="range"
id="outputWidth"
name="outputWidth"
min="20"
max="100"
value="60"
/>
</div>
<div>
<label for="fontFamily">Estilo da Fonte: </label>
<select 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
type="checkbox"
id="uppercaseCheckbox"
name="uppercaseCheckbox"
/>
</div>
<!-- Botão para apagar preferências -->
<button id="resetPreferences">Resetar Preferências</button>
</div>
<div class="output" id="output">As legendas aparecerão aqui...</div>
<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 finalTranscript = '';
recognition.onresult = (event) => {
let interimTranscript = '';
for (let i = event.resultIndex; i < event.results.length; i++) {
const transcript = event.results[i][0].transcript;
if (event.results[i].isFinal) {
finalTranscript += transcript + ' '; // Adiciona um espaço após cada transcrição final
} else {
interimTranscript += transcript;
}
}
output.textContent = finalTranscript + interimTranscript;
// Reseta o temporizador cada vez que um novo resultado é capturado
clearTimeout(timeoutId);
// Inicia um novo temporizador
timeoutId = setTimeout(() => {
finalTranscript = '';
output.textContent = '';
}, 2000); // 3000 ms (3 segundos) é o tempo de espera; ajuste conforme necessário
};
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;
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('button1').addEventListener('click', function () {
window.location.href = 'https://navve.studio/legenda/index.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();
};
</script>
</body>
</html>