Skip to content

Commit 6369b4f

Browse files
committed
fix: improve text handling and playback conditions in ChatOperationButton
--bug=1058408 --user=刘瑞斌 【应用管理】移动端自动播放没有声音,浏览器可正常播放 https://www.tapd.cn/62980211/s/1729308
1 parent b89ee3d commit 6369b4f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class AudioManage {
293293
const newTextList = textList.slice(this.textList.length)
294294
// 没有新增段落
295295
if (newTextList.length <= 0) {
296-
return
296+
return 0
297297
}
298298
newTextList.forEach((text, index) => {
299299
this.textList.push(text)
@@ -429,7 +429,10 @@ class AudioManage {
429429
}
430430
if (text) {
431431
const textList = this.getTextList(text, is_end ? true : false)
432-
this.appendTextList(textList)
432+
if (this.appendTextList(textList) !== 0) {
433+
// 没有新增段落
434+
return
435+
}
433436
}
434437
// 如果存在在阅读的元素则直接返回
435438
if (this.statusList.some((item) => [AudioStatus.PLAY_INT].includes(item))) {
@@ -472,7 +475,7 @@ class AudioManage {
472475
setTimeout(() => {
473476
speechSynthesis.speak(audioElement)
474477
this.statusList[index] = AudioStatus.PLAY_INT
475-
}, 100)
478+
}, 500)
476479
}
477480
}
478481
}
@@ -533,7 +536,7 @@ onMounted(() => {
533536
const record_id = data.record_id
534537
bus.emit('play:pause', record_id)
535538
if (props.data.record_id == record_id) {
536-
if (props.tts && props.tts_autoplay) {
539+
if (props.tts && props.tts_autoplay && data.is_end) {
537540
if (audioManage.value) {
538541
audioManage.value.play(props.data.answer_text, data.is_end)
539542
}

0 commit comments

Comments
 (0)