fix: Fix browser text to speech cannot resume and cancel
--bug=1052345 --user=刘瑞斌 【github#2352】【应用】使用浏览器内置TTS,切换历史记录内容播放会没有声音 https://www.tapd.cn/57709429/s/1657771
This commit is contained in:
parent
76e6b6e276
commit
5eec0f7975
@ -200,7 +200,7 @@ const playAnswerTextPart = () => {
|
|||||||
if (audioList.value[currentAudioIndex.value] !== utterance.value?.text) {
|
if (audioList.value[currentAudioIndex.value] !== utterance.value?.text) {
|
||||||
window.speechSynthesis.cancel()
|
window.speechSynthesis.cancel()
|
||||||
}
|
}
|
||||||
if (window.speechSynthesis.paused) {
|
if (window.speechSynthesis.paused && audioList.value[currentAudioIndex.value] === utterance.value?.text) {
|
||||||
window.speechSynthesis.resume()
|
window.speechSynthesis.resume()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -176,7 +176,7 @@ const playAnswerTextPart = () => {
|
|||||||
if (audioList.value[currentAudioIndex.value] !== utterance.value?.text) {
|
if (audioList.value[currentAudioIndex.value] !== utterance.value?.text) {
|
||||||
window.speechSynthesis.cancel()
|
window.speechSynthesis.cancel()
|
||||||
}
|
}
|
||||||
if (window.speechSynthesis.paused) {
|
if (window.speechSynthesis.paused && audioList.value[currentAudioIndex.value] === utterance.value?.text) {
|
||||||
window.speechSynthesis.resume()
|
window.speechSynthesis.resume()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -321,6 +321,14 @@ const clickListHandle = (item: any) => {
|
|||||||
currentChatName.value = item.abstract
|
currentChatName.value = item.abstract
|
||||||
if (currentChatId.value !== 'new') {
|
if (currentChatId.value !== 'new') {
|
||||||
getChatRecord()
|
getChatRecord()
|
||||||
|
|
||||||
|
// 切换对话后,取消暂停的浏览器播放
|
||||||
|
if (window.speechSynthesis.paused && window.speechSynthesis.speaking) {
|
||||||
|
window.speechSynthesis.resume()
|
||||||
|
nextTick(() => {
|
||||||
|
window.speechSynthesis.cancel()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (common.isMobile()) {
|
if (common.isMobile()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user