You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.bs
+88-46Lines changed: 88 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,8 @@ This does not preclude adding support for this as a future API enhancement, and
118
118
</li>
119
119
120
120
<li>The user agent may also give the user a longer explanation the first time speech input is used, to let the user know what it is and how they can tune their privacy settings to disable speech recording if required.</li>
121
+
122
+
<li>To mitigate the risk of fingerprinting, user agents MUST NOT personalize speech recognition when performing speech recognition on a {{MediaStreamTrack}}.</li>
A {{SpeechRecognitionMode}} enum to determine where speech recognition takes place. The initial value is <code>ondevice-preferred</code>.
160
+
A boolean flag indicating whether recognition <em class="rfc2119" title="MUST">MUST</em> be performed locally. The initial value is <code>false</code>.
<dd>This attribute, when set to true, indicates a requirement that the speech recognition process <em class="rfc2119" title="MUST">MUST</em> be performed locally on the user's device.
320
+
If set to false, the user agent can choose between local and remote processing.
@@ -389,46 +380,93 @@ See <a href="https://lists.w3.org/Archives/Public/public-speech-api/2012Sep/0072
389
380
The user agent must raise an <a event for=SpeechRecognition>end</a> event once the speech service is no longer connected.
390
381
If the abort method is called on an object which is already stopped or aborting (that is, start was never called on it, the <a event for=SpeechRecognition>end</a> or <a event for=SpeechRecognition>error</a> event has fired on it, or abort was previously called on it), the user agent must ignore the call.</dd>
The {{SpeechRecognition/availableOnDevice}} method returns a {{Promise}} that resolves to a {{AvailabilityStatus}} indicating the on-device speech recognition availability for a given [[!BCP47]] language tag.
385
+
The {{SpeechRecognition/available}} method returns a {{Promise}} that resolves to a {{AvailabilityStatus}} indicating the recognition availability matching the {{SpeechRecognitionOptions}} argument.
395
386
396
387
When invoked, run these steps:
397
388
1. Let <var>promise</var> be <a>a new promise</a>.
398
-
1. Run the <a>on-device availability algorithm</a> with <var>lang</var> and <var>promise</var>. If it returns an exception, throw it and abort these steps.
389
+
1. Run the <a>availability algorithm</a> with <var>options</var> and <var>promise</var>. If it returns an exception, throw it and abort these steps.
The {{SpeechRecognition/installOnDevice}} method returns a {{Promise}} that resolves to a {{boolean}} when and whether the installation of on-device speech recognition for a given [[!BCP47]] language tag succeeded.
395
+
The {{SpeechRecognition/install}} method attempts to install speech recognition language packs for all languages specified in `options.langs`.
396
+
It returns a {{Promise}} that resolves to a {{boolean}}.
397
+
The promise resolves to `true` when all installation attempts for requested and supported languages succeed (or the languages were already installed).
398
+
The promise resolves to `false` if `options.langs` is empty, if not all of the requested languages are supported, or if any installation attempt for a supported language fails.
405
399
406
400
When invoked, run these steps:
407
401
1. If the [=current settings object=]'s [=relevant global object=]'s [=associated Document=] is NOT [=fully active=], throw an {{InvalidStateError}} and abort these steps.
408
-
1. If <var>lang</var> is not a valid [[!BCP47]] language tag, throw a {{SyntaxError}} and abort these steps.
409
-
1. If the on-device speech recognition language pack for <var>lang</var> is unsupported, return a resolved {{Promise}} with false and skip the rest of these steps.
402
+
1. If any <var>lang</var> in {{SpeechRecognitionOptions/langs}} of <var>options</var> is not a valid [[!BCP47]] language tag, throw a {{SyntaxError}} and abort these steps.
403
+
1. If the on-device speech recognition language pack for any <var>lang</var> in {{SpeechRecognitionOptions/langs}} of <var>options</var> is unsupported, return a resolved {{Promise}} with false and skip the rest of these steps.
410
404
1. Let <var>promise</var> be <a>a new promise</a>.
411
-
1. Initiate the download of the on-device speech recognition language for <var>lang</var>.
405
+
1. For each <var>lang</var> in {{SpeechRecognitionOptions/langs}} of <var>options</var>, initiate the download of the on-device speech recognition language for <var>lang</var>.
412
406
<p class=note>
413
407
Note: The user agent can prompt the user for explicit permission to download the on-device speech recognition language pack.
414
408
</p>
415
409
1. [=Queue a task=] on the [=relevant global object=]'s [=task queue=] to run the following step:
416
-
- If the download succeeds, resolve <var>promise</var> with <code>true</code>, otherwise resolve it with <code>false</code>.
410
+
- When the download of all languages specified by {{SpeechRecognitionOptions/langs}} of <var>options</var> succeeds, resolve <var>promise</var> with <code>true</code>, otherwise resolve it with <code>false</code>.
417
411
<p class="note">
418
412
Note: The <code>false</code> resolution of the Promise does not indicate the specific cause of failure. User agents are encouraged to provide more detailed information about the failure in developer tools console messages. However, this detailed error information is not exposed to the script.
419
413
</p>
420
414
1. Return <var>promise</var>.
415
+
<p class=note>
416
+
{{SpeechRecognitionOptions/processLocally}} of <var>options</var> is not used in this algorithm.
417
+
</p>
421
418
</dd>
422
419
423
420
</dl>
424
-
<p>When the <dfn>on-device availability algorithm</dfn> with <var>lang</var> and <var>promise</var> is invoked, the user agent MUST run the following steps:
<dd>Indicates that speech recognition is not available for the specified language(s) and processing preference.
427
+
If {{SpeechRecognitionOptions/processLocally}} of <var>options</var> is `true`, this means on-device recognition for the language is not supported by the user agent.
428
+
If {{SpeechRecognitionOptions/processLocally}} of <var>options</var> is `false`, it means neither local nor remote recognition is available for at least one of the specified languages.</dd>
<dd>Indicates that on-device speech recognition for the specified language(s) is supported by the user agent but not yet installed. It can potentially be installed using the {{SpeechRecognition/install()}} method. This status is primarily relevant when {{SpeechRecognitionOptions/processLocally}} of <var>options</var> is true.</dd>
<dd>Indicates that on-device speech recognition for the specified language(s) is currently in the process of being downloaded. This status is primarily relevant when {{SpeechRecognitionOptions/processLocally}} of <var>options</var> is true.</dd>
<dd>Indicates that speech recognition is available for all specified language(s) and the given processing preference.
438
+
If {{SpeechRecognitionOptions/processLocally}} of <var>options</var> is true, this means on-device recognition is installed and ready.
439
+
If {{SpeechRecognitionOptions/processLocally}} of <var>options</var> is false, it means recognition (which could be local or remote) is available.</dd>
440
+
</dl>
441
+
442
+
<p>When the <dfn>availability algorithm</dfn> with <var>options</var> and <var>promise</var> is invoked, the user agent MUST run the following steps:
425
443
1. If the [=current settings object=]'s [=relevant global object=]'s [=associated Document=] is NOT [=fully active=], throw an {{InvalidStateError}} and abort these steps.
426
-
1. If <var>lang</var> is not a valid [[!BCP47]] language tag, throw a {{SyntaxError}} and abort these steps.
427
-
1. Determine the availability status for <var>lang</var>:
428
-
- If the on-device speech recognition language pack for <var>lang</var> is unsupported, let <var>status</var> be {{AvailabilityStatus/unavailable}}.
429
-
- Else if the on-device speech recognition language pack for <var>lang</var> is supported but not installed, let <var>status</var> be {{AvailabilityStatus/downloadable}}.
430
-
- Else if the on-device speech recognition language pack for <var>lang</var> is downloading, let <var>status</var> be {{AvailabilityStatus/downloading}}.
431
-
- Else if the on-device speech recognition language pack for <var>lang</var> is installed, let <var>status</var> be {{AvailabilityStatus/available}}.
444
+
1. Let <var>langs</var> be {{SpeechRecognitionOptions/langs}} of <var>options</var>.
445
+
1. If any <var>lang</var> in <var>langs</var> is not a valid [[!BCP47]] language tag, throw a {{SyntaxError}} and abort these steps.
446
+
1. If {{SpeechRecognitionOptions/processLocally}} of <var>options</var> is `false`:
447
+
1. If <var>langs</var> is an empty sequence, let <var>status</var> be {{AvailabilityStatus/unavailable}}.
448
+
1. Else if speech recognition (which may be remote) is available for all <var>language</var> in <var>langs</var>, let <var>status</var> be {{AvailabilityStatus/available}}.
449
+
1. Else, let <var>status</var> be {{AvailabilityStatus/unavailable}}.
450
+
1. If {{SpeechRecognitionOptions/processLocally}} of <var>options</var> is `true`:
451
+
<ol type=a>
452
+
<li>If <var>langs</var> is an empty sequence, let <var>status</var> be {{AvailabilityStatus/unavailable}}.</li>
453
+
<li>Else:
454
+
<ol type=i>
455
+
<li>Let <var>finalStatus</var> be {{AvailabilityStatus/available}}.</li>
456
+
<li>For each <var>language</var> in <var>langs</var>:
457
+
<ol>
458
+
<li>Let <var>currentLanguageStatus</var>.</li>
459
+
<li>If on-device speech recognition for <var>language</var> is installed, set <var>currentLanguageStatus</var> to {{AvailabilityStatus/available}}.</li>
460
+
<li>Else if on-device speech recognition for <var>language</var> is currently being downloaded, set <var>currentLanguageStatus</var> to {{AvailabilityStatus/downloading}}.</li>
461
+
<li>Else if on-device speech recognition for <var>language</var> is supported by the user agent but not yet installed, set <var>currentLanguageStatus</var> to {{AvailabilityStatus/downloadable}}.</li>
462
+
<li>Else (on-device speech recognition for <var>language</var> is not supported), set <var>currentLanguageStatus</var> to {{AvailabilityStatus/unavailable}}.</li>
463
+
<li>If <var>currentLanguageStatus</var> comes after <var>finalStatus</var> in the ordered list `[{{AvailabilityStatus/available}}, {{AvailabilityStatus/downloading}}, {{AvailabilityStatus/downloadable}}, {{AvailabilityStatus/unavailable}}]`, set <var>finalStatus</var> to <var>currentLanguageStatus</var>.</li>
464
+
</ol>
465
+
</li>
466
+
<li>Let <var>status</var> be <var>finalStatus</var>.</li>
467
+
</ol>
468
+
</li>
469
+
</ol>
432
470
1. [=Queue a task=] on the [=relevant global object=]'s [=task queue=] to run the following step:
433
471
- Resolve <var>promise</var> with <var>status</var>.
434
472
@@ -439,9 +477,13 @@ following steps:
439
477
1. If the [=current settings object=]'s [=relevant global object=]'s
440
478
[=associated Document=] is NOT [=fully active=], throw an {{InvalidStateError}}
441
479
and abort these steps.
442
-
1. If {{[[started]]}} is `true` and no <a event
443
-
for=SpeechRecognition>error</a> or <a event for=SpeechRecognition>end</a> event
444
-
have fired, throw an {{InvalidStateError}} and abort these steps.
480
+
1. If {{SpeechRecognition/[[started]]}} is `true` and no <a event
481
+
for=SpeechRecognition>error</a> event or <a event for=SpeechRecognition>end</a> event
482
+
has fired on it, throw an {{InvalidStateError}} and abort these steps.
483
+
1. If this.{{SpeechRecognition/[[processLocally]]}} is `true`:
484
+
a. If the user agent determines that local speech recognition is not available for this.{{SpeechRecognition/lang}}, or if it cannot fulfill the local processing requirement for other reasons:
485
+
i. [=Queue a task=] to [=fire an event=] named `error` at `this`. The event's `error` attribute <em class="rfc2119" title="MUST">MUST</em> be {{SpeechRecognitionErrorCode/service-not-allowed}}. The event's `message` attribute <em class="rfc2119" title="MUST">MUST</em> provide an implementation-defined string detailing the reason.
486
+
ii. Abort these steps.
445
487
1. Set {{[[started]]}} to `true`.
446
488
1. If |requestMicrophonePermission| is `true` and [=request
447
489
permission to use=] "`microphone`" is [=permission/"denied"=], abort
0 commit comments