-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.html
More file actions
44 lines (41 loc) · 1.22 KB
/
Copy pathcontrol.html
File metadata and controls
44 lines (41 loc) · 1.22 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>IoT</title>
</head>
<body>
<p id="temperatura"> Cargando...</p>
<button id="escuchar">Escuchar</button>
<h2 id="status"></h2>
<script>
const voz = new webkitSpeechRecognition();
const buton= document.getElementById("escuchar")
const status= document.getElementById("status")
buton.addEventListener("click", correr)
voz.lang="es-MX"
voz.onresult= mostrar;
function correr(eve){
voz.start()
status.innerHTML="escuchando..."
}
function mostrar(resultados){
var mensaje = resultados.results[0][0].transcript;
var confianza = parseInt(resultados.results[0][0].confidence * 100)
mensaje = mensaje.toLowerCase()
status.innerHTML = mensaje+ "-"+confianza+"%";
fetch("/mensaje",{
method:'post',
headers:{
'Accept':'application/json, text/plain, */*',
'Content-Type':'application/json'
},
body:JSON.stringify({mensaje:mensaje})
}).then(function()
{console.log("MENSAJE ENVIADO")})
}
</script>
</body>
</html>