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

197
Vistas
How to play audio from an API response?

I'm not able to play audio from the below response. How can I convert that below response and play it.

getAudio = async () => {
try {
const url = `example`;

const r = await fetch(url).then(r => r.text());
const len = r.length;

let audioURL = "";

if (len > 200) {
  const buf = new ArrayBuffer(len);
  const view = new Uint8Array(buf);

  for (let i = 0; i < len; i++) view[i] = r.charCodeAt(i) & 0xff;

  const blob = new Blob([view], { type: "audio/wav" });

  audioURL = window.URL.createObjectURL(blob);
} else toast("No audio found!", { type: "error" });

this.setState({ audioURL });
} catch (e) {
console.log(e);
}
};

Response is

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I would try to use Axios instead of Fetch, Its more useful in my opinion, Other than that, try setting up an error boundary around the definition of blob, I truly believes the problem lays there.

Good luck!

about 4 years ago · Juan Pablo Isaza Denunciar
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