browser-compat-data icon indicating copy to clipboard operation
browser-compat-data copied to clipboard

api.SpeechRecognition.continuous - false unsupported in Safari

Open tsegreto opened this issue 2 years ago • 4 comments

What type of issue is this?

Browser bug (a bug with a feature that may impact site compatibility)

What information was incorrect, unhelpful, or incomplete?

Safari does not honor SpeechRecognition.continuous being set to false. It does not stop listening after it stops. See my StackOverflow post: https://stackoverflow.com/questions/75498609/safari-webkitspeechrecognition-continuous-bug

What browsers does this problem apply to, if applicable?

No response

What did you expect to see?

Detailing this bug in Safari

Did you test this? If so, how?

Read: https://stackoverflow.com/questions/75498609/safari-webkitspeechrecognition-continuous-bug

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?

https://stackoverflow.com/questions/75498609/safari-webkitspeechrecognition-continuous-bug

Do you have anything more you want to share?

No response

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/continuous

MDN metadata

MDN page report details
  • Query: api.SpeechRecognition.continuous
  • Report started: 2023-03-09T13:50:26.194Z

tsegreto avatar Mar 09 '23 15:03 tsegreto

Oof, I ran into this as well. Thank you for your StackOverflow post.

Safari does seem to respond to the continuous flag; it only emits an end event when continuous is set to false. I tested on Safari 16.5.2 on MacOS 11.7.10.

Here's a standalone HTML file that reproduces the behavior that results are still emitted even though continuous has not been set (and so defaults to false).

<!DOCTYPE html>
<html>

<head>
  <title>Safari Speech Recognition Is Always Continuous</title>
</head>

<body>
  <p>Click anywhere to start speech recognition. The expected behavior is that the browser stops listening after the `end` event fires, but it seems that Safari continues to listen and return results.</p>
</body>

<script>
  document.onclick = async () => {
    const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
    const recognition = new SpeechRecognition();
    recognition.onend = (event) => {
      document.body.innerHTML += `<p>End</p>`;
    };
    recognition.onresult = (event) => {
      document.body.innerHTML += `<p>Result: ${event.results[event.results.length - 1][0].transcript}</p>`;
    };
    document.body.innerHTML = '<p>Listening...</p>';
    recognition.start();
  };
</script>

</html>

paulkernfeld avatar Mar 21 '24 20:03 paulkernfeld

@tsegreto @paulkernfeld Can you confirm whether you still experience the issue in the latest Safari version? (I cannot reproduce it locally with Safari 18.2.)

It was probably fixed with https://github.com/WebKit/WebKit/commit/68c30e63bd2664d632c899686f369678e11685a7 (https://bugs.webkit.org/show_bug.cgi?id=252936) in WebKit 616.1.4 between Safari 16.6/615.3.12 and Safari 17/616.1.27.

caugner avatar Jan 22 '25 17:01 caugner

Sorry, I'm on Intel so I think I probably can't upgrade to that version of Safari (I'm on 16.6.1 now).

paulkernfeld avatar Jan 22 '25 17:01 paulkernfeld

Based on current evidence in this issue, we should update the Safari statement for continuous, splitting it up into [{ version_added: "14.1", version_removed: "17", partial_implementation: true, notes: "Returns multiple results when set to `false`." }, { version_added: "17" }]:

https://github.com/mdn/browser-compat-data/blob/7d5252f3ad23908e699751e36163825fd9125e61/api/SpeechRecognition.json#L222-L224

caugner avatar Jun 13 '25 11:06 caugner