Article From:https://segmentfault.com/q/1010000011117398
Question:

You want to call the voice synthesis interface on the H5 page, using Baidu’s rest API, (not knowing you can do it), and ask for a binary voice file by document, but don’t know how to use it.
According to the document, the header information is Content-type: audio/mp3, even if it is successful.

Corresponding information

How can I analyze the audio and read it out, or do I use the wrong way? Ask the big God to give a plan or method

Answer 0:

Knowledge point: blob

$.ajax({
    url:"http://localhost:3333/audio",
    type:"post",
}).done(res=>{
    const blob = new Blob([res],{type:"audio/mp3"});
    const blobUrl = URL.createObjectURL(blob);
    const audio = new Audio(blobUrl);
    audio.play();
});

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *