| | |
| | | |
| | | // 是否已接口相应 |
| | | const isReceiveRes = ref(false); |
| | | const humanIsLoading = ref(true); |
| | | |
| | | const digitalHumanIsShow = ref(false); |
| | | const closeDigitalHuman = () => { |
| | |
| | | }; |
| | | |
| | | const resetDuixStatus = () => { |
| | | humanIsLoading.value = true; |
| | | isReceiveRes.value = false; |
| | | // isSpeaking.value = false; |
| | | digitalHumanIsShow.value = false; |
| | |
| | | } |
| | | return acc + mdText; |
| | | }, ''); |
| | | console.log('🚀 ~ knowledgeText:', knowledgeText); |
| | | // const conclusionText = |
| | | // item.conclusion |
| | | // ?.filter((item) => !!item.report) |
| | |
| | | }; |
| | | |
| | | let isWaitingSpeak = false; |
| | | |
| | | const speakContent = (content: string) => { |
| | | // 打断之前的已收到xxx |
| | | duix.break(); |
| | | isWaitingSpeak = false; |
| | | duix.speak({ |
| | | content, |
| | | }); |
| | | }; |
| | | |
| | | const initDuix = () => { |
| | | const sign = duixConfig.sign; // sign由服务端生成 |
| | | const conversationId = duixConfig.conversationId; // duix平台会话id |
| | |
| | | duix.on('intialSucccess', () => { |
| | | console.info('intialSucccess'); |
| | | // 此时初始化成功,可调用start |
| | | duix.start({ conversationId, openAsr: true }).then((res) => { |
| | | duix.start({ conversationId, openAsr: true,wipeGreen:true }).then((res) => { |
| | | console.info('start', res); |
| | | }); |
| | | }); |
| | |
| | | }); |
| | | duix.on('show', () => { |
| | | console.info('show'); |
| | | humanIsLoading.value = false; |
| | | // 此时可确认视频已 |
| | | // (document.querySelector('#modal') as HTMLElement).style.display = 'none'; |
| | | }); |
| | |
| | | console.info('speakStart', data); |
| | | }); |
| | | duix.on('speakEnd', (data) => { |
| | | isReceiveRes.value = false; |
| | | if (!isWaitingSpeak) { |
| | | isReceiveRes.value = false; |
| | | } |
| | | }); |
| | | duix.on('speakSection', (data) => { |
| | | console.info('speakSection', data); |
| | |
| | | }); |
| | | duix.on('asrResult', (data) => { |
| | | console.info('asrResult', data); |
| | | |
| | | if (isReceiveRes.value) { |
| | | return; |
| | | } |
| | |
| | | let hasResult = false; |
| | | isReceiveRes.value = true; |
| | | try { |
| | | // isWaitingSpeak = true; |
| | | // duix.speak({ |
| | | // content: '已收到您的问题,正在思考中...请稍等', |
| | | // }); |
| | | isWaitingSpeak = true; |
| | | duix.speak({ |
| | | content: '已收到您的问题,正在思考中...请稍等', |
| | | }); |
| | | questionStreamByPost( |
| | | { |
| | | question: data, |
| | |
| | | if (chunkRes.mode === 'result' && chunkRes.value?.answer_type === 'knowledge') { |
| | | const plainText = getPlainText(chunkRes.value); |
| | | hasResult = true; |
| | | duix.speak({ |
| | | content: plainText, |
| | | }); |
| | | } |
| | | |
| | | if (!chunkRes.value?.json_ok && chunkRes.value?.err_code === 'MESSAGE') { |
| | | speakContent(plainText); |
| | | } else if (!chunkRes.value?.json_ok && chunkRes.value?.err_code === 'MESSAGE') { |
| | | if (hasResult) return; |
| | | hasResult = true; |
| | | isWaitingSpeak = false; |
| | | |
| | | duix.speak({ |
| | | content: chunkRes.value.json_msg, |
| | | }); |
| | | speakContent(chunkRes.value.json_msg); |
| | | } |
| | | |
| | | if (chunkRes.mode === 'finish') { |
| | | if (!hasResult) { |
| | | isWaitingSpeak = false; |
| | | duix.speak({ |
| | | content: '暂时无法口头描述你所说的问题', |
| | | }); |
| | | speakContent('暂时无法口头描述你所说的问题'); |
| | | } else { |
| | | hasResult = false; |
| | | } |
| | |
| | | openDigitalHuman, |
| | | isHumanTalking: isReceiveRes, |
| | | closeDigitalHuman, |
| | | humanIsLoading, |
| | | }; |
| | | }; |