Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
Calling Async function inside Web Speech API function

I'm trying to get the text from audio using Web Speech API, pass that text to the API call, and display the result with textarea. Each function works fine when called separately. But once I tried to connect them, textarea displays nothing.

<button id="start-recording" onclick="recognition.start()">Start</button>
<textarea id="results"></textarea>
<script type="text/javascript">
      const recognition = new webkitSpeechRecognition();
      const resultpreview = document.getElementById("results");

      recognition.onresult = function (event) {
        if (event.results.length > 0) {
          const text = event.results[0][0].transcript;
          callAPI(text);
        }
      };

      const callAPI = async (text) => {
        var requestJson = {
          access_key: access_key,
          argument: {
            text: text,
            analysis_code: analysisCode,
          },
        };

        const response = await fetch(myURL, {
          method: "POST",
          body: JSON.stringify(requestJson),
          headers: { "Content-Type": "application/json; charset=UTF-8" },
        });

        const myJson = await response.json();
        const words = myJson.return_object.sentence[0].NE;

        for (const word of words) {
          resultpreview.innerHTML += word.text;
        }
      };
</script>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda