DHEIVER commited on
Commit
c2e01d5
·
verified ·
1 Parent(s): 093b595

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +27 -27
index.js CHANGED
@@ -1,31 +1,31 @@
1
- // app.js
 
 
 
2
 
3
- document.addEventListener('DOMContentLoaded', function () {
4
- const statusElement = document.getElementById('status');
5
- const outputElement = document.getElementById('output');
6
- const commandButton = document.getElementById('commandButton');
 
 
7
 
8
- // Função para simular uma atualização de status
9
- function updateStatus() {
10
- fetch('status.json')
11
- .then(response => response.json())
12
- .then(data => {
13
- statusElement.textContent = `Status: ${data.status}`;
14
- });
15
- }
16
-
17
- // Função para simular uma resposta de comando
18
- function sendCommand() {
19
- fetch('command.json')
20
- .then(response => response.json())
21
- .then(data => {
22
- outputElement.textContent = `Comando recebido: ${data.command}`;
23
- });
24
- }
25
 
26
- // Atualizar o status quando a página carrega
27
- updateStatus();
 
 
 
28
 
29
- // Adicionar evento ao botão
30
- commandButton.addEventListener('click', sendCommand);
31
- });
 
 
 
 
 
 
1
+ document.getElementById('startButton').addEventListener('click', () => {
2
+ const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
3
+ recognition.lang = 'pt-BR';
4
+ recognition.start();
5
 
6
+ recognition.onresult = (event) => {
7
+ const transcript = event.results[0][0].transcript;
8
+ console.log('Você disse:', transcript);
9
+ // Enviar o texto para o processamento de linguagem natural
10
+ processText(transcript);
11
+ };
12
 
13
+ recognition.onerror = (event) => {
14
+ console.error('Erro no reconhecimento de voz:', event.error);
15
+ };
16
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ function speak(text) {
19
+ const utterance = new SpeechSynthesisUtterance(text);
20
+ utterance.lang = 'pt-BR';
21
+ window.speechSynthesis.speak(utterance);
22
+ }
23
 
24
+ function processText(text) {
25
+ // Aqui você pode adicionar a lógica de processamento de linguagem natural
26
+ // Por exemplo, usar uma API como Dialogflow, IBM Watson, etc.
27
+ // Para este exemplo, vamos apenas repetir o texto
28
+ const response = `Você disse: ${text}`;
29
+ document.getElementById('response').textContent = response;
30
+ speak(response);
31
+ }