Skip to content

Conversation

@evanbliu
Copy link
Collaborator

@evanbliu evanbliu commented Feb 20, 2025

Closes #141

This PR contains the following changes:

  • Introduce a new AvailabilityStatus enum to indicate the availability of on-device speech recognition for a given language.
  • Update the availableOnDevice method to return a Promise that resolves to an AvailabilityStatus instead of a boolean.
  • Rewrite the availableOnDevice and installOnDevice methods in the modern, algorithmic style.

Preview | Diff

@evanbliu evanbliu requested a review from padenot February 20, 2025 22:01
@evanbliu
Copy link
Collaborator Author

@padenot - Can you please take a look at this PR when you get a chance? Thanks!

@padenot
Copy link
Member

padenot commented Feb 28, 2025

Sorry to be picky, but I think it's good to get things right from the get-go to get the ball rolling on the first few PRs. Apart from the "when do we know downloading has finished", my comments are on the form rather than the substance of the PR, but unfortunately that matters in normative writing.

@evanbliu evanbliu requested a review from padenot March 5, 2025 00:57
Copy link
Member

@padenot padenot left a comment

Choose a reason for hiding this comment

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

Way better, still some comments.

How does one know that the model has finished downloaded?

@evanbliu
Copy link
Collaborator Author

evanbliu commented Mar 5, 2025

Way better, still some comments.

How does one know that the model has finished downloaded?

From above:
Right now sites will have to poll availableOnDevice to find out if the download has finished.

What are your thoughts on either:

  1. Introducing a new languageinstalled SpeechRecognition event.
  2. Introducing a new API that returns a Promise that resolves to true once the language is finished or resolves to false if the installation failed.
  3. Updating installOnDevice to resolve to true once on-device speech recognition is installed rather than resolving to true when the installation is initiated.
  4. Just require websites to poll availableOnDevice.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 5, 2025
This CL updates the return type of the availableOnDevice API to reflect
the spec changes in this PR: github.com/WebAudio/web-speech-api/pull/143

Bug:40286514
Change-Id: I66e4a18e5cdaf262cecd847eca6b2205618028ef
@evanbliu evanbliu requested a review from padenot March 6, 2025 00:31
@beaufortfrancois
Copy link
Contributor

aarongable pushed a commit to chromium/chromium that referenced this pull request Mar 6, 2025
This CL updates the return type of the availableOnDevice API to reflect
the spec changes in this PR: github.com/WebAudio/web-speech-api/pull/143

Bug: 40286514
Change-Id: I66e4a18e5cdaf262cecd847eca6b2205618028ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6299973
Reviewed-by: Tom Sepez <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1429100}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 6, 2025
This CL updates the return type of the availableOnDevice API to reflect
the spec changes in this PR: github.com/WebAudio/web-speech-api/pull/143

Bug: 40286514
Change-Id: I66e4a18e5cdaf262cecd847eca6b2205618028ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6299973
Reviewed-by: Tom Sepez <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1429100}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 6, 2025
This CL updates the return type of the availableOnDevice API to reflect
the spec changes in this PR: github.com/WebAudio/web-speech-api/pull/143

Bug: 40286514
Change-Id: I66e4a18e5cdaf262cecd847eca6b2205618028ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6299973
Reviewed-by: Tom Sepez <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1429100}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Mar 17, 2025
…API, a=testonly

Automatic update from web-platform-tests
Update return type of availableOnDevice API

This CL updates the return type of the availableOnDevice API to reflect
the spec changes in this PR: github.com/WebAudio/web-speech-api/pull/143

Bug: 40286514
Change-Id: I66e4a18e5cdaf262cecd847eca6b2205618028ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6299973
Reviewed-by: Tom Sepez <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1429100}

--

wpt-commits: 95c04e58fe733a0e93682aa2c7dd1dc37913c1b8
wpt-pr: 51148
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Mar 18, 2025
…API, a=testonly

Automatic update from web-platform-tests
Update return type of availableOnDevice API

This CL updates the return type of the availableOnDevice API to reflect
the spec changes in this PR: github.com/WebAudio/web-speech-api/pull/143

Bug: 40286514
Change-Id: I66e4a18e5cdaf262cecd847eca6b2205618028ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6299973
Reviewed-by: Tom Sepez <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1429100}

--

wpt-commits: 95c04e58fe733a0e93682aa2c7dd1dc37913c1b8
wpt-pr: 51148
@evanbliu
Copy link
Collaborator Author

Gentle ping -- @padenot - Do you have any additional comments on this CL, or on how the API for detecting if the download has finished should look like?

@evanbliu
Copy link
Collaborator Author

Gentle ping -- @padenot - Do you have any additional comments on this CL, or on how the API for detecting if the download has finished should look like?

I'd like to propose option 3: update installOnDevice to resolve to true once on-device speech recognition is installed rather than resolving to true when the installation is initiated.

The Promise will resolve to false if the download fails for any reason (i.e. user rejects the download, network issues, unsupported language) and resolve to true once the language is installed and ready. I don't think the delay should be much of an issue because in most cases the download would complete relatively quickly. Of course, there will be some cases in which the download takes much longer, but the current installOnDevice API could also take a long time to resolve to True if the user takes awhile to respond to a prompt, so websites will need to handle this delay already anyways.

@padenot
Copy link
Member

padenot commented Mar 27, 2025

Yes, I'd tend to agree. We could imagine having a UA-side progress indicator here.

@evanbliu
Copy link
Collaborator Author

Sounds good, I've updated the spec to reflect this. Let me know if you have any other comments or concerns on this PR!

Copy link
Member

@padenot padenot left a comment

Choose a reason for hiding this comment

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

Looks good, some comments, but nothing too important. If the answer to the last sentence of the 3rd comment is yes, this is good for merging w/ the small adjustment I mentioned.

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

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to evanbliu/speech-api that referenced this pull request Apr 2, 2025
SHA: bad1722
Reason: push, by evanbliu

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
jwidar pushed a commit to jwidar/LatencyZeroGithub that referenced this pull request Sep 16, 2025
…API, a=testonly

Automatic update from web-platform-tests
Update return type of availableOnDevice API

This CL updates the return type of the availableOnDevice API to reflect
the spec changes in this PR: github.com/WebAudio/web-speech-api/pull/143

Bug: 40286514
Change-Id: I66e4a18e5cdaf262cecd847eca6b2205618028ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6299973
Reviewed-by: Tom Sepez <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1429100}

--

wpt-commits: 95c04e58fe733a0e93682aa2c7dd1dc37913c1b8
wpt-pr: 51148
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 changing return type of availableOnDevice()

4 participants