This commit is contained in:
parent
75564a95f0
commit
8f979f5478
|
@ -152,6 +152,8 @@ async function loadTTS() {
|
|||
|
||||
// 监听到文本数据改变
|
||||
const watchTTS = watch(() => props.tts, async (n: any, o: any) => {
|
||||
console.log('文本变化', n);
|
||||
|
||||
if (props.tts == '') {
|
||||
for (let i = 0; i < audioElements.length; i++) {
|
||||
audioElements[i].pause()
|
||||
|
|
|
@ -438,26 +438,51 @@ async function onConversation() {
|
|||
// }
|
||||
// }
|
||||
|
||||
socket.onmessage = (event: any)=>{
|
||||
console.log(event.data);
|
||||
lastText+=event.data;
|
||||
socket.onmessage = (e: any)=>{
|
||||
console.log(e.data);
|
||||
let event = {
|
||||
data: {
|
||||
event: '',
|
||||
text: '',
|
||||
tts_text: ''
|
||||
}
|
||||
};
|
||||
event.data = JSON.parse(e.data);
|
||||
const loading = false;
|
||||
nowStart.value = false;
|
||||
if(!event.data.includes('[finish]')) updateChat(
|
||||
event.data.tts_text != '' ? tts.push(event.data.tts_text) : null
|
||||
if(!event.data.event.includes('finish')) {
|
||||
lastText+=event.data.text;
|
||||
updateChat(
|
||||
+uuid,
|
||||
dataSources.value.length - 1,
|
||||
{
|
||||
dateTime: new Date().toLocaleString(),
|
||||
text: lastText,
|
||||
inversion: false,
|
||||
tts: JSON.stringify(+uuid),
|
||||
tts: JSON.stringify(tts),
|
||||
error: false,
|
||||
loading,
|
||||
conversationOptions: { conversationId: uuid, parentMessageId: uuid },
|
||||
requestOptions: { prompt: message, options: { ...options } },
|
||||
},
|
||||
)
|
||||
else{
|
||||
} else if(event.data.tts_text){
|
||||
updateChat(
|
||||
+uuid,
|
||||
dataSources.value.length - 1,
|
||||
{
|
||||
dateTime: new Date().toLocaleString(),
|
||||
text: lastText,
|
||||
inversion: false,
|
||||
tts: JSON.stringify(tts),
|
||||
error: false,
|
||||
loading,
|
||||
conversationOptions: { conversationId: uuid, parentMessageId: uuid },
|
||||
requestOptions: { prompt: message, options: { ...options } },
|
||||
},
|
||||
)
|
||||
} else{
|
||||
// 关闭连接
|
||||
nowStatus.value = 'input'
|
||||
socket.close()
|
||||
|
|
Loading…
Reference in New Issue