JPLTedCas commited on
Commit
8c30780
1 Parent(s): dcffac3

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +17 -9
templates/index.html CHANGED
@@ -1,23 +1,30 @@
1
  <!DOCTYPE html>
2
  <html>
3
  <head>
4
- <title>WebSockets y Reconocimiento de Voz</title>
5
  </head>
6
  <body>
 
7
  <div id="output"></div>
8
- <button onclick="startRecognition()">Comenzar Reconocimiento</button>
9
  <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js"></script>
10
  <script>
11
- const socket = io.connect('https://' + document.domain + ':' + location.port);
 
 
12
 
13
- socket.on('response', function (message) {
14
- const output = document.getElementById('output');
15
- output.innerHTML = message;
 
 
 
 
 
16
  });
17
 
18
- function startRecognition() {
19
- socket.emit('recognize_speech');
20
- }
21
  </script>
22
  </body>
23
  </html>
@@ -25,3 +32,4 @@
25
 
26
 
27
 
 
 
1
  <!DOCTYPE html>
2
  <html>
3
  <head>
4
+ <title>Reconocimiento de Voz en Español</title>
5
  </head>
6
  <body>
7
+ <button id="startRecognition">Iniciar Reconocimiento</button>
8
  <div id="output"></div>
 
9
  <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js"></script>
10
  <script>
11
+ const socket = io.connect('http://' + document.domain + ':' + location.port);
12
+ const startRecognitionButton = document.getElementById('startRecognition');
13
+ const outputDiv = document.getElementById('output');
14
 
15
+ startRecognitionButton.addEventListener('click', function () {
16
+ const recognition = new webkitSpeechRecognition();
17
+ recognition.lang = 'es-ES'; // Configura el idioma a español (España)
18
+ recognition.onresult = function (event) {
19
+ const result = event.results[0][0].transcript;
20
+ socket.emit('recognize_speech', result);
21
+ };
22
+ recognition.start();
23
  });
24
 
25
+ socket.on('response', function (data) {
26
+ outputDiv.innerHTML = `Texto reconocido: ${data}`;
27
+ });
28
  </script>
29
  </body>
30
  </html>
 
32
 
33
 
34
 
35
+