Open Bug 1751633 Opened 4 years ago Updated 3 years ago

speechSynthesis.speak() speechSynthesis.pause() call sequence handled incorrectly

Categories

(Core :: Web Speech, defect)

Firefox 98
defect

Tracking

()

UNCONFIRMED

People

(Reporter: czerny.jakub, Unassigned)

References

Details

Attachments

(3 files)

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)

  1. Repeatedly evaluate following snippet in DevTools console
speechSynthesis.cancel()
utt = new SpeechSynthesisUtterance("hello world")
utt.addEventListener('start', event => console.log('start'))
utt.addEventListener('end', event => console.log('end'))
utt.addEventListener('error', event => console.log('error'))
utt.addEventListener('pause', event => console.log('pause'))
utt.addEventListener('resume', event => console.log('resume'))
speechSynthesis.speak(utt)
speechSynthesis.pause()
console.log('speaking=', speechSynthesis.speaking, 'paused=', speechSynthesis.paused)

Actual results:

During first evaluation the text is read and events 'start' and 'end' are fired.
During subsequent evaluations no text is read and no events are fires.
All evaluations produces console output

speaking= false paused= true

If after second and following evaluations speechSynthesis.resume() is called, the text is read and events start and end are fired.

Expected results:

All evaluations should not read any text and events 'start' and 'pause' should be fired.

speechSynthesis should end up in state speaking=true, paused=true - already reported as Issue 1751621

Calling speechSynthesis.resume() after the second and following evaluations should read the text and fire events resume and end.

Has STR: --- → yes
Component: Untriaged → Web Speech
Product: Firefox → Core
See Also: → 1686927

Hi,
I've tried to reproduce on my end:

Actual results:
During first evaluation the text is not read and events 'start' and 'end' are not fired, but speaking= false paused= true instead (as in my screenshot)
During subsequent evaluations no text is read and speaking= false paused= true events are fired.
If after second and following evaluations speechSynthesis.resume() is called, the text is read and events start and end are fired.

Let me know if I missed any steps to be able to reproduce exactly what you're experiencing.
Best,
Clara

Flags: needinfo?(czerny.jakub)
Attached image image.png

Hi,

  • I can confirm that your console screenshot seems to correspond to your description
  • As far as I can tell I did the same thing (screenshot attached) on current Nightly 98.0a1 (2022-01-29) (64-bit) and result was as described in original report - text is read and events start and end are fired only during first evaluation. Subsequent evaluations (there are two of them in the screenshot) are eventless and silent. I'm not sure what might be the cause of the difference.
  • Both actual scenarios seems buggy to me though, since IIUIC
    • state speaking= false paused= true should never happen - whenever paused is set, speaking should be set too
    • when speech synthesis becomes paused, pause event should be fired
    • repeated evaluation should produce same results

Regards
Jakub

Flags: needinfo?(czerny.jakub)

The severity field is not set for this bug.
:anatal, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(anatal)
Flags: needinfo?(anatal) → needinfo?(eitan)

Like I said in bug 1751621, calling speak/pause/resume/cancel are asynchronous, so you can't expect the state of the synthesis to be determinate when they are called. A more reliable way of writing the snippet above is this:

speechSynthesis.cancel()
utt = new SpeechSynthesisUtterance("hello world")
utt.addEventListener('start', event => {
  console.log('start')
  speechSynthesis.pause()
})
utt.addEventListener('end', event => console.log('end'))
utt.addEventListener('error', event => console.log('error'))
utt.addEventListener('pause', event => {
  console.log('pause')
  console.log('speaking=', speechSynthesis.speaking, 'paused=', speechSynthesis.paused)
})
utt.addEventListener('resume', event => console.log('resume'))
speechSynthesis.speak(utt)
Flags: needinfo?(eitan)
Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: