This commit is contained in:
weipengfei 2023-10-13 21:42:43 +08:00
parent fcba21d708
commit 9670a54747
1 changed files with 13 additions and 10 deletions

View File

@ -110,18 +110,21 @@ const http = (text: any)=>{
}); });
}) })
} }
let ttsList = [];
async function loadTTS(){ async function loadTTS(){
let tts = props.tts?JSON.parse(props.tts):[] let tts = props.tts?JSON.parse(props.tts):[]
for(let i=0;i<tts.length;i++){ if(tts.length>ttsList.length){
let res = await http(tts[i]) for(let i=ttsList.length;i<tts.length;i++){
const a = new Audio(res.data.mp3) let res = await http(tts[i])
a.addEventListener('ended', () => { const a = new Audio(res.data.mp3)
onAudioEnd() a.addEventListener('ended', () => {
}) onAudioEnd()
audioElements.push(a) })
if (i == 0) audioElements.push(a)
playAudio() if (i == 0)
playAudio()
}
ttsList = tts;
} }
} }