Skip to content

Conversation

@evanbliu
Copy link
Collaborator

@evanbliu evanbliu commented Jun 23, 2025

This PR replaces SpeechRecognitionPhraseList with ObservableArray.

Closes #168


Preview | Diff

index.bs Outdated
attribute unsigned long maxAlternatives;
attribute boolean processLocally;
attribute SpeechRecognitionPhraseList phrases;
attribute sequence<SpeechRecognitionPhrase> phrases;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is invalid Web IDL; attributes cannot be sequences.

ObservableArray is probably the correct choice here. See https://webidl.spec.whatwg.org/#idl-observable-array

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh good call, I'll switch this to ObservableArray

@evanbliu evanbliu changed the title Replace SpeechRecognitionPhraseList with a sequence Replace SpeechRecognitionPhraseList with an ObservableArray Jun 24, 2025
@evanbliu
Copy link
Collaborator Author

On second thought, I'm questioning if this is the right thing to do here for the following reasons:

  1. The browser won't be modifying the SpeechRecognitionPhrases, so there's no need for websites to observe changes to this collection and using ObservableArray would imply that the browser's speech engine might add or remove the phrases in the list.
  2. I didn't find any other examples of APIs with ObservableArrays as attributes. In Chromium, there's only one non-test usage of ObservableArray.
  3. There's already a precedent of creating a new interface type with the sole purpose of encapsulating a collection (e.g. SpeechRecognitionPhraseList, TouchList, FileList).

My suggestion is to keep the SpeechRecognitionPhraseList as-is, or alternatively use a FrozenArray it's crucial to avoid adding a new type. @domenic - What are your thoughts on this?

@domenic
Copy link

domenic commented Jun 26, 2025

It's indeed crucial to avoid adding new fake arrays to the web platform. That is a strongly deprecated practice.

The question is whether you want this to be mutable, or only settable by the constructor. If it's supposed to be mutable, ObservableArray is the right choice. If it's only settable by the constructor, then adding a constructor option (that would be a sequence<>) and changing the type to readonly FrozenArray<T> makes sense.

Some recent discussion about this in whatwg/webidl#1495 (comment).

@evanbliu
Copy link
Collaborator Author

I see, it sounds like ObservableArray would be the best choice here since it's mutable.

Do you know why there's still only a single usage of the ObservableArray in Chromium despite being introduced 4 years ago?

@domenic
Copy link

domenic commented Jun 27, 2025

I think it's a matter of successive filtering. You'd need:

  • To produce a new API
  • That needs an array-like type
  • That fits into cases (2) or (3) of my linked comment, instead of (1) or (4).

I think it's pretty reasonable to expect only one API to meet those filters over the course of 4 years. We don't create that many new APIs, period, as an absolute number.

@evanbliu evanbliu merged commit 4d6e11e into WebAudio:main Jul 7, 2025
1 check passed
github-actions bot added a commit that referenced this pull request Jul 7, 2025
SHA: 4d6e11e
Reason: push, by evanbliu

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jul 7, 2025
…itionPhrase>

This CL replaces SpeechRecognitionPhraseList with ObservableArray<SpeechRecognitionPhrase>.

Spec changes: WebAudio/web-speech-api#169

Bug:381349238
Change-Id: I9cb4bdafd7c74cf48a4d7f3684af644df1eff4c0
aarongable pushed a commit to chromium/chromium that referenced this pull request Jul 8, 2025
…itionPhrase>

This CL replaces SpeechRecognitionPhraseList with ObservableArray<SpeechRecognitionPhrase>.

Spec changes: WebAudio/web-speech-api#169

Bug: 381349238
Change-Id: I9cb4bdafd7c74cf48a4d7f3684af644df1eff4c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6696798
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1483461}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jul 8, 2025
…itionPhrase>

This CL replaces SpeechRecognitionPhraseList with ObservableArray<SpeechRecognitionPhrase>.

Spec changes: WebAudio/web-speech-api#169

Bug: 381349238
Change-Id: I9cb4bdafd7c74cf48a4d7f3684af644df1eff4c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6696798
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1483461}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jul 8, 2025
…itionPhrase>

This CL replaces SpeechRecognitionPhraseList with ObservableArray<SpeechRecognitionPhrase>.

Spec changes: WebAudio/web-speech-api#169

Bug: 381349238
Change-Id: I9cb4bdafd7c74cf48a4d7f3684af644df1eff4c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6696798
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1483461}
lando-prod-mozilla bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Jul 12, 2025
… ObservableArray<SpeechRecognitionPhrase>, a=testonly

Automatic update from web-platform-tests
Replace SpeechRecognitionPhraseList with ObservableArray<SpeechRecognitionPhrase>

This CL replaces SpeechRecognitionPhraseList with ObservableArray<SpeechRecognitionPhrase>.

Spec changes: WebAudio/web-speech-api#169

Bug: 381349238
Change-Id: I9cb4bdafd7c74cf48a4d7f3684af644df1eff4c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6696798
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1483461}

--

wpt-commits: 82b74727278342807e9b42c9f29ecc7bdddc0495
wpt-pr: 53634
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Jul 15, 2025
… ObservableArray<SpeechRecognitionPhrase>, a=testonly

Automatic update from web-platform-tests
Replace SpeechRecognitionPhraseList with ObservableArray<SpeechRecognitionPhrase>

This CL replaces SpeechRecognitionPhraseList with ObservableArray<SpeechRecognitionPhrase>.

Spec changes: WebAudio/web-speech-api#169

Bug: 381349238
Change-Id: I9cb4bdafd7c74cf48a4d7f3684af644df1eff4c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6696798
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1483461}

--

wpt-commits: 82b74727278342807e9b42c9f29ecc7bdddc0495
wpt-pr: 53634
github-actions bot added a commit to evanbliu/speech-api that referenced this pull request Aug 26, 2025
…#169)

SHA: 4d6e11e
Reason: push, by evanbliu

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider replacing SpeechRecognitionPhraseList with sequence<SpeechRecognitionPhrase>

4 participants