This commit is contained in:
weipengfei 2023-10-13 21:37:55 +08:00
parent 3ae1ea5dc8
commit 4e310b1a05
1 changed files with 17 additions and 9 deletions

View File

@ -95,25 +95,33 @@ async function handleCopy() {
import axios from "axios"
function loadTTS(){
let tts = props.tts?JSON.parse(props.tts):[]
for(let i=0;i<tts.length;i++){
const http = ()=>{
return new Promise((resolve, reject)=>{
axios.post('https://chat.lihaink.cn/index/tts',{data: '你好'})
.then(response => {
//
console.log('请求成功',response.data);
const a = new Audio(response.data.mp3)
resolve(response.data)
})
.catch(error => {
//
console.error('请求失败',error);
reject(error)
});
})
}
async function loadTTS(){
let tts = props.tts?JSON.parse(props.tts):[]
for(let i=0;i<tts.length;i++){
let res = await http(tts[i])
const a = new Audio(res.data.mp3)
a.addEventListener('ended', () => {
onAudioEnd()
})
audioElements.push(a)
if (i == 0)
playAudio()
})
.catch(error => {
//
console.error('请求失败',error);
});
}
}