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) => {
|
const watchTTS = watch(() => props.tts, async (n: any, o: any) => {
|
||||||
|
console.log('文本变化', n);
|
||||||
|
|
||||||
if (props.tts == '') {
|
if (props.tts == '') {
|
||||||
for (let i = 0; i < audioElements.length; i++) {
|
for (let i = 0; i < audioElements.length; i++) {
|
||||||
audioElements[i].pause()
|
audioElements[i].pause()
|
||||||
|
|
|
@ -438,26 +438,51 @@ async function onConversation() {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
socket.onmessage = (event: any)=>{
|
socket.onmessage = (e: any)=>{
|
||||||
console.log(event.data);
|
console.log(e.data);
|
||||||
lastText+=event.data;
|
let event = {
|
||||||
|
data: {
|
||||||
|
event: '',
|
||||||
|
text: '',
|
||||||
|
tts_text: ''
|
||||||
|
}
|
||||||
|
};
|
||||||
|
event.data = JSON.parse(e.data);
|
||||||
const loading = false;
|
const loading = false;
|
||||||
nowStart.value = 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,
|
+uuid,
|
||||||
dataSources.value.length - 1,
|
dataSources.value.length - 1,
|
||||||
{
|
{
|
||||||
dateTime: new Date().toLocaleString(),
|
dateTime: new Date().toLocaleString(),
|
||||||
text: lastText,
|
text: lastText,
|
||||||
inversion: false,
|
inversion: false,
|
||||||
tts: JSON.stringify(+uuid),
|
tts: JSON.stringify(tts),
|
||||||
error: false,
|
error: false,
|
||||||
loading,
|
loading,
|
||||||
conversationOptions: { conversationId: uuid, parentMessageId: uuid },
|
conversationOptions: { conversationId: uuid, parentMessageId: uuid },
|
||||||
requestOptions: { prompt: message, options: { ...options } },
|
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'
|
nowStatus.value = 'input'
|
||||||
socket.close()
|
socket.close()
|
||||||
|
|
Loading…
Reference in New Issue