Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the on-device speech recognition methods #143

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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!

index.bs Outdated
1. If the on-device speech recognition language pack for <var>lang</var> is unsupported, return {{AvailabilityStatus/unavailable}}.
1. If the on-device speech recognition language pack for <var>lang</var> is supported but not installed, return {{AvailabilityStatus/downloadable}}.
1. If the on-device speech recognition language pack for <var>lang</var> is downloading, return {{AvailabilityStatus/downloading}}.
1. If the on-device speech recognition language pack for <var>lang</var> is installed, return {{AvailabilityStatus/available}}.
Copy link
Member

Choose a reason for hiding this comment

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

When do we know it has finished downloading?

@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}
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