SpeechSynthesisUtterance 未触发 "mark" 事件
SpeechSynthesisUtterance not triggering "mark" events
我无法触发 mark
event of a SpeechSynthesisUtterance
实例。
据我所知,这应该可行。我希望看到
Started
Reached mark
Done
相反,我得到
Started
Done
document.querySelector('#play').addEventListener('click', function speak() {
const utterance = new SpeechSynthesisUtterance(
`<?xml version="1.0"?>
<speak version="1.1">Foo <mark name="bar" /> baz.</speak>`
)
const log = document.getElementById('log')
utterance.addEventListener('start', () => {log.value = 'Started\n'})
utterance.addEventListener('mark', () => {log.value += 'Reached mark\n'})
utterance.addEventListener('end', () => {log.value += 'Done\n'})
log.value = 'Waiting…'
speechSynthesis.cancel()
speechSynthesis.speak(utterance)
})
<textarea id="log" disabled rows="3">Waiting…</textarea>
<hr>
<button id="play">Speak</button>
很抱歉通知您这是一个错误,SSML 尚未实现。
https://github.com/WICG/speech-api/issues/10
https://bugs.chromium.org/p/chromium/issues/detail?id=88072
您会看到 chronium 问题已有 9 年历史,所以我怀疑它是否会很快得到解决。
我无法触发 mark
event of a SpeechSynthesisUtterance
实例。
据我所知,这应该可行。我希望看到
Started
Reached mark
Done
相反,我得到
Started
Done
document.querySelector('#play').addEventListener('click', function speak() {
const utterance = new SpeechSynthesisUtterance(
`<?xml version="1.0"?>
<speak version="1.1">Foo <mark name="bar" /> baz.</speak>`
)
const log = document.getElementById('log')
utterance.addEventListener('start', () => {log.value = 'Started\n'})
utterance.addEventListener('mark', () => {log.value += 'Reached mark\n'})
utterance.addEventListener('end', () => {log.value += 'Done\n'})
log.value = 'Waiting…'
speechSynthesis.cancel()
speechSynthesis.speak(utterance)
})
<textarea id="log" disabled rows="3">Waiting…</textarea>
<hr>
<button id="play">Speak</button>
很抱歉通知您这是一个错误,SSML 尚未实现。
https://github.com/WICG/speech-api/issues/10
https://bugs.chromium.org/p/chromium/issues/detail?id=88072
您会看到 chronium 问题已有 9 年历史,所以我怀疑它是否会很快得到解决。