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

150
Views
¿Cómo agregar alineación forzada a la API de voz web de Chrome?

Estoy usando un fragmento de código modificado de uno de los ejemplos de mdn. De todos modos, podemos hacer que este código devuelva una de las palabras de las phrases exclusivamente y ninguna otra palabra. Cualquier alternativa también sería apreciada, si esto no es posible.

 var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition; var SpeechGrammarList = SpeechGrammarList || webkitSpeechGrammarList; var SpeechRecognitionEvent = SpeechRecognitionEvent || webkitSpeechRecognitionEvent; var resultPara = document.querySelector(".result"); var testBtn = document.querySelector("button"); const phrases = ["dummy phrase"]; function testSpeech() { testBtn.disabled = true; testBtn.textContent = "Listening"; // To ensure case consistency while checking with the returned output text resultPara.textContent = ""; var recognition = new SpeechRecognition(); var speechRecognitionList = new SpeechGrammarList(); phrases.forEach((phrase) => { const grammar = "#JSGF V1.0; grammar phrase; public <phrase> = " + phrase + ";"; speechRecognitionList.addFromString(grammar, 1); }); recognition.grammars = speechRecognitionList; recognition.lang = "en-US"; recognition.interimResults = false; recognition.maxAlternatives = 1; recognition.start(); recognition.onresult = function (event) { var speechResult = event.results[0][0].transcript.toLowerCase(); console.log("Speech received: " + speechResult + "."); resultPara.textContent = speechResult; console.log("Confidence: " + event.results[0][0].confidence); }; recognition.onspeechend = function () { recognition.stop(); testBtn.disabled = false; testBtn.textContent = "Start new test"; }; recognition.onerror = function (event) { testBtn.disabled = false; testBtn.textContent = "Start new test"; console.error("Error occurred in recognition: " + event.error); }; } testBtn.addEventListener("click", testSpeech);
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!