How to save audio data (binary array) with js

< H2 > 1. How JavaScript saves data and converts it to the corresponding format < / H2 >

currently working on an iFLYTEK voice (text-to-voice demo)
when I get the data from iFLYTEK
the data are as follows:

clipboard.png

Pythondemo

clipboard.png
A writeFile completes the writing of the file, even the format of the file (I don"t know Python, and I don"t know whether the writing here is correct).

so what should be used to write in JavaScript

< H2 > 2. Goals and ideas < / H2 >

goal: to convert text to speech

ideas:

  1. get the audio data and save it as a wav format file, and then play the file through audio
  2. get the audio data and play it directly (how to implement it)
< H2 > 3. Related environment < / H2 >
  1. browser: Google
  2. Framework: Vue
  3. UI: Element UI
< H2 > 4. Try to solve < / H2 >
  1. adopt blob

Source of ideas ( papersnake )

// 
if (response.headers["content-type"] === "audio/mpeg") {
    const blob = new Blob([response.data], {type: "audio/wav"})
    const blobUrl = URL.createObjectURL(blob)
    const audio = new Audio(blobUrl)
    audio.play()
}

result:
whether to solve: yes
there is a problem: the returned content is base64-encoded content that needs to be converted

< H2 > 5. Related information < / H2 >
  1. iFLYTEK speech synthesis

if you are running in a browser, the biggest hurdle should be that the browser cannot operate on local files.
you can consider blob


buddy. Have you solved it? I will make an error in, DOMException: Failed to load because no supported source was found.


the first way of thinking. Is there a solution that can be saved before playing? ask for

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e512f0-6572a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e512f0-6572a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?