Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
webkitSpeechRecognition siempre solicita acceso al micrófono cada vez que ejecuto la función que lo llama

Estoy creando un asistente virtual con html y js, y funciona, pero cada vez que presiona el botón "Preguntar algo", solicitará acceso al micrófono, incluso después de que le di acceso antes. ¿Hay alguna forma de evitar eso? Creo que podría ser que lo esté ejecutando directamente desde mi carpeta, así que ¿sería útil si lo tengo en un servidor o algo así? Aquí está mi código:

 <!DOCTYPE html> <html> <body> <button onclick="sListening()">Ask something</button> <br> <br> <div id="a"> <small>z</small>zZ... </div> <script> var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition; var recognition = new SpeechRecognition(); // This runs when the speech recognition service starts recognition.onstart = function() { document.getElementById("a").innerHTML = "<b>!</b>" }; recognition.onspeechend = function() { // when user is done speaking recognition.stop(); } // This runs when the speech recognition service returns result recognition.onresult = function(event) { var transcript = event.results[0][0].transcript; process(transcript, "a"); var confidence = event.results[0][0].confidence; }; function ranarr(arr) { return arr[Math.floor(Math.random() * arr.length)]; } function process(text, div) { document.getElementById(div).innerText = text; text = text.toLowerCase(); var r = "I don't understand."; var hiarr = ['Sup?', 'Howdy.', 'Hello!', 'Well hello to you to!'] text = text.split(/([!,?,.,\s])/); if (text.includes("hi") || text.includes("hello")) { r = ranarr(hiarr) } let utterance = new SpeechSynthesisUtterance(r); speechSynthesis.speak(utterance); } // start recognition function sListening() { recognition.start(); } </script> </body> </html>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!