Skip to content

Commit fef50de

Browse files
Update on-device explainer (#149)
Co-authored-by: Evan Liu <evliu@google.com>
1 parent bad1722 commit fef50de

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

explainers/on-device-speech-recognition.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ Applications can offer speech recognition capabilities even without an active in
2323

2424
## New Methods
2525

26-
### 1. `Promise<boolean> onDeviceWebSpeechAvailable(DOMString lang)`
26+
### 1. `Promise<boolean> availableOnDevice(DOMString lang)`
2727
This method checks if on-device speech recognition is available for a specific language. Developers can use this to determine whether to enable on-device features or fall back to cloud-based recognition.
2828

2929
#### Example Usage
3030
```javascript
3131
const lang = 'en-US';
32-
SpeechRecognition.onDeviceWebSpeechAvailable(lang).then((available) => {
32+
SpeechRecognition.availableOnDevice(lang).then((available) => {
3333
if (available) {
3434
console.log(`On-device speech recognition is available for ${lang}.`);
3535
} else {
@@ -38,15 +38,18 @@ SpeechRecognition.onDeviceWebSpeechAvailable(lang).then((available) => {
3838
});
3939
```
4040

41-
### 2. `Promise<boolean> installOnDeviceSpeechRecognition()`
42-
This method initiates the installation of resources required for on-device speech recognition. The installation process may download and configure necessary language models.
41+
### 2. `Promise<boolean> installOnDevice()`
42+
This method install the resources required for on-device speech recognition. The installation process may download and configure necessary language models.
4343

4444
#### Example Usage
4545
```javascript
46-
SpeechRecognition.installOnDeviceSpeechRecognition().then(() => {
47-
console.log('Installation of on-device speech recognition resources initiated successfully.');
48-
}).catch((error) => {
49-
console.error('Unable to install on-device speech recognition:', error);
46+
const lang = 'en-US';
47+
SpeechRecognition.installOnDevice(lang).then((success) => {
48+
if (success) {
49+
console.log('On-device speech recognition resources installed successfully.');
50+
} else {
51+
console.error('Unable to install on-device speech recognition.');
52+
}
5053
});
5154
```
5255

0 commit comments

Comments
 (0)