currently working on an iFLYTEK voice (text-to-voice demo)
when I get the data from iFLYTEK
the data are as follows:
Pythondemo
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:
- get the audio data and save it as a wav format file, and then play the file through audio
- get the audio data and play it directly (how to implement it)
- browser: Google
- Framework: Vue
- UI: Element UI
- 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