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

196
Views
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 answers
Answer question

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 Report
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!