-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfileRead.html
More file actions
43 lines (34 loc) · 909 Bytes
/
fileRead.html
File metadata and controls
43 lines (34 loc) · 909 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Texto para Voz</title>
</head>
<body>
<input type="file" id="arquivo" accept=".txt">
<button onclick="lerArquivo()">Selecionar Arquivo</button>
<button onclick="falar()">Falar</button>
<script>
let textoParaFalar = '';
function lerArquivo() {
const fileInput = document.getElementById('arquivo');
const file = fileInput.files[0];
const reader = new FileReader();
reader.onload = function(event) {
textoParaFalar = event.target.result;
};
reader.readAsText(file);
}
function falar() {
if (textoParaFalar === '') {
alert('Por favor, selecione um arquivo de texto.');
return;
}
var synth = window.speechSynthesis;
var utterance = new SpeechSynthesisUtterance(textoParaFalar);
synth.speak(utterance);
}
</script>
</body>
</html>