speechSynthesis.speaking is false while speechSynthesis.paused is true
Categories
(Core :: Web Speech, defect)
Tracking
()
People
(Reporter: czerny.jakub, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0
Steps to reproduce:
Version: 98.0a1 (2022-01-23) (64-bit), applies to current stable version 96.0.1 (64-bit) as well
- Open a page
- Open DevTools console
- Evaluate
speechSynthesis.cancel()
utt = new SpeechSynthesisUtterance("hello world")
speechSynthesis.speak(utt)
speechSynthesis.pause()
console.log('speaking=', speechSynthesis.speaking, 'paused=', speechSynthesis.paused)
Actual results:
console output:
speaking= false paused= true
Expected results:
According to https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis/speaking
returns true if an utterance is currently in the process of being spoken — even if SpeechSynthesis is in a paused state.
IIUIC whenever speechSynthesis.paused
is true
, speechSynthesis.speaking
should be true
as well
Updated•3 years ago
|
Comment 1•3 years ago
|
||
The severity field is not set for this bug.
:anatal, could you have a look please?
For more information, please visit auto_nag documentation.
Updated•2 years ago
|
Comment 2•2 years ago
|
||
This API is asynchronous, so if you call pause immediately after calling speak, and if you query speaking
and paused
immediately after that you will get indeterminate results. From an implementation perspective what is happening is that the utterance is queued and being processed, and hasn't started speaking yet, so the status of speaking
is false. On the other hand, when you call pause()
it will immediately put the speech queue into a paused state, so no new utterances will begin speaking. That is how you end up with speaking=false and paused=true.
I tried this on other browsers like Safari and Chrome and got a more confusing result of speaking=true, paused=false. So there isn't consistency on that front either. But to be fair, like I said, the result would be indeterminate since these are all potentially async operations. If you were to wait for the speak()
and pause()
methods to resolve with the start
and paused
DOM events respectively, you will get the result you expect:
speechSynthesis.cancel();
utt = new SpeechSynthesisUtterance("hello world");
utt.addEventListener("start", () => {
speechSynthesis.pause();
});
utt.addEventListener("pause", () => {
console.log('speaking=', speechSynthesis.speaking, 'paused=', speechSynthesis.paused);
});
speechSynthesis.speak(utt);
Updated•2 years ago
|
Description
•