Open Bug 1522074 Opened 6 years ago Updated 3 years ago

speechSynthesis cancel wipes out speak calls following directly after

Categories

(Core :: Web Speech, enhancement)

All
Other
enhancement

Tracking

()

UNCONFIRMED

People

(Reporter: masterjames, Unassigned)

Details

(Whiteboard: [specification][type:bug])

Attachments

(1 obsolete file)

What did you do?

If you have the speechSynthesis.speaking at the time and call cancel you then call speech to start a new.

What happened?

It fails to play the new sound requested directly after a previous utterance speaking had cancel called.
It takes maybe 500 milliseconds before a new speak call for an utterance will not get cancelled too.

What should have happened?

You should maybe have a function to halt/stop and removal all utterances from the speechSynthesis queue (especially since it's a singlton styled class I believe [aka only one instance]). BTW I like the idea of keeping the utterances for reuse later I don't think that has any baring but is also what makes sense.

Is there anything else we should know?

Well there seems to be a couple of option to cover both that there is a way to just stop everything and start a new, 'speak' could have an option to stop and clear the queue before playing the new sound and not queuing it. As in some instances they could be quite a read.
Anyway it's an inconvenience to the coder it seems unclear how to do that and my attempts resulted in a setTimeout delay after canceling of about 500 millsecs to assure it will play the utterance desired instead.

I'm in Chrome but you have the document I use maybe I'm in the wrong location for reporting this?

Component: API → Untriaged
Product: developer.mozilla.org → Firefox

Not sure if this is the correct component, but please correct it as such if this is not the case.

Component: Untriaged → Audio/Video
Product: Firefox → Core

This issue should be in web speech component.

Component: Audio/Video → Web Speech

I've got more to add to this now.
https://jsfiddle.net/MasterJames/3nxygaze/20/

It seems putting a call to ss.resume() after the cancel() and second speak() call, will achieve the desired effect but this is not intuitive or properly documented I guess.

see additional info on other thread
https://bugzilla.mozilla.org/show_bug.cgi?id=1523920

(In reply to masterjames from comment #8)

I've got more to add to this now.
https://jsfiddle.net/MasterJames/3nxygaze/20/

It seems putting a call to ss.resume() after the cancel() and second speak() call, will achieve the desired effect but this is not intuitive or properly documented I guess.

I can hear a voice saying "not playing anything after clear" in Firefox Nightly on my MacBook.

specifically, the following code works for me.

let uttr1 = new SpeechSynthesisUtterance("some message that goes on longer");
let uttr2 = new SpeechSynthesisUtterance("playing anything after cancel");
speechSynthesis.speak(uttr1);
speechSynthesis.cancel();
speechSynthesis.speak(uttr2);

It works in the first time but not the second time. In the second time, the problem is that the utterance is already used. This problem will be solved in bug 1523920. It's a different problem.

masterjames, can you still reproduce this problem?

Flags: needinfo?(masterjames)

The problem is still there in the latest Firefox (72.0.1 build 20200107212822).

It says in the chrome bug report how to fix it. (Pass NULL instead of empty string to API inside clear).

<html>
<head>
  <meta charset="utf-8">
  <title></title>
</head>
<body>
  <script>
    const synth = window.speechSynthesis;
    synth.addEventListener("voiceschanged", populateVoiceList);
    
    var voices = null;
    
    function populateVoiceList() {
      voices = synth.getVoices();
    }
    
    populateVoiceList();
    
    var u = new SpeechSynthesisUtterance("First");
    var u2 = new SpeechSynthesisUtterance("Second");
    u.voice = voices[0];
    u2.voice = voices[0];
    synth.speak(u);
    synth.cancel();
    synth.speak(u2);
  
  </script>
</body>
</html>

Cancel now leaves current utterance to be dequeued on end. Dequeuing current
utterance immediately would result in a newly queued utterance unintentionally
dequeued on end.

Assignee: nobody → luka.zitnik
Attachment #9131721 - Attachment description: Bug 1522074 - Dequeue canceled on end only. → Bug 1522074 - Dequeue canceled on end only. r=eeejay,aryx
Attachment #9131721 - Attachment is obsolete: true
Assignee: luka.zitnik → nobody

In the version 77.0.1 20200602222727.
When opening the sample I posted above in a new tab, it works (it says "second"). But reloading the page, either using F5 or the location bar and enter, doesn't create any sound at all.

This must be a defect. I suggest changing the bug type from "enhancement" to "defect".

Clear a needinfo that is pending on an inactive user.

For more information, please visit auto_nag documentation.

Flags: needinfo?(masterjames)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: