From 2de635f812c2061d41cf2a0c49ad6a0311210190 Mon Sep 17 00:00:00 2001 From: Evan Liu Date: Mon, 23 Jun 2025 16:31:35 -0700 Subject: [PATCH 1/2] Replace SpeechRecognitionPhraseList with sequence --- index.bs | 69 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 66 deletions(-) diff --git a/index.bs b/index.bs index 0638cba..55e6c8c 100644 --- a/index.bs +++ b/index.bs @@ -163,7 +163,7 @@ The term "interim result" indicates a {{SpeechRecognitionResult}} in which the {
: [[phrases]] :: - A {{SpeechRecognitionPhraseList}} representing a list of phrases for contextual biasing. The initial value is null. + A sequence of {{SpeechRecognitionPhrase}} representing a list of phrases for contextual biasing. The initial value is an empty sequence.
@@ -178,7 +178,7 @@ interface SpeechRecognition : EventTarget { attribute boolean interimResults; attribute unsigned long maxAlternatives; attribute boolean processLocally; - attribute SpeechRecognitionPhraseList phrases; + attribute sequence<SpeechRecognitionPhrase> phrases; // methods to drive the speech interaction undefined start(); @@ -298,16 +298,6 @@ interface SpeechRecognitionPhrase { readonly attribute DOMString phrase; readonly attribute float boost; }; - -// The object representing a list of phrases for contextual biasing. -[SecureContext, Exposed=Window] -interface SpeechRecognitionPhraseList { - constructor(sequence<SpeechRecognitionPhrase> phrases); - readonly attribute unsigned long length; - SpeechRecognitionPhrase item(unsigned long index); - undefined addItem(SpeechRecognitionPhrase item); - undefined removeItem(unsigned long index); -};

SpeechRecognition Attributes

@@ -354,7 +344,7 @@ interface SpeechRecognitionPhraseList {
The setter steps are: - 1. If the {{SpeechRecognitionPhraseList/length}} of the given value is greater than 0 and the system does not support contextual biasing, + 1. If the size of the given value is greater than 0 and the system does not support contextual biasing, throw a {{SpeechRecognitionErrorEvent}} with the {{phrases-not-supported}} error code and abort these steps. 1. Set {{SpeechRecognition/[[phrases]]}} to the given value. 1. Send a copy of {{SpeechRecognition/[[phrases]]}} to the system for initializing or updating the phrases for contextual biasing implementation. @@ -727,59 +717,6 @@ For a non-continuous recognition it will hold only a single value.

This attribute returns the value of {{[[boost]]}}.
-

SpeechRecognitionPhraseList

- -

The SpeechRecognitionPhraseList object holds a list of phrases for contextual biasing and has the following internal slot:

- -
- : [[phrases]] - :: - A list of {{SpeechRecognitionPhrase}} representing the phrases to be boosted. The initial value is an empty list. -
- -
-
SpeechRecognitionPhraseList(|phrases|) constructor
-
- When this constructor is invoked, run the following steps: - 1. Let |list| be a new object of type {{SpeechRecognitionPhraseList}}. - 1. Set |list|.{{SpeechRecognitionPhraseList/[[phrases]]}} to be the value of |phrases|. - 1. Return |list|. -
- -
length attribute
-
- This attribute indicates the number of phrases in the list. - When invoked, return the number of items in {{SpeechRecognitionPhraseList/[[phrases]]}}. -
- -
item(|index|) method
-
- This method gets the {{SpeechRecognitionPhrase}} object at the |index| of the list. - When invoked, run the following steps: - 1. If |index| is smaller than 0, or greater than or equal to {{SpeechRecognitionPhraseList/length}}, - throw a {{RangeError}} and abort these steps. - 1. Return the {{SpeechRecognitionPhrase}} at the |index| of {{SpeechRecognitionPhraseList/[[phrases]]}}. -
- -
addItem(|item|) method
-
- This method adds the {{SpeechRecognitionPhrase}} object |item| to the list. - When invoked, add |item| to the end of {{SpeechRecognitionPhraseList/[[phrases]]}}. - The list is allowed to have multiple {{SpeechRecognitionPhrase}} objects with the same {{SpeechRecognitionPhrase/[[phrase]]}} value, - and the speech recognition model should use the last {{SpeechRecognitionPhrase/[[boost]]}} value - for this {{SpeechRecognitionPhrase/[[phrase]]}} in the list. -
- -
removeItem(|index|) method
-
- This method removes the {{SpeechRecognitionPhrase}} object at the |index| of the list. - When invoked, run the following steps: - 1. If |index| is smaller than 0, or greater than or equal to {{SpeechRecognitionPhraseList/length}}, - throw a {{RangeError}} and abort these steps. - 1. Remove the {{SpeechRecognitionPhrase}} object at the |index| of {{SpeechRecognitionPhraseList/[[phrases]]}}. -
-
-

SpeechGrammar

The SpeechGrammar object represents a container for a grammar.

From 6ca1d23361fc307ab1a8ec9be10f3672bb9c4324 Mon Sep 17 00:00:00 2001 From: Evan Liu Date: Mon, 23 Jun 2025 16:31:35 -0700 Subject: [PATCH 2/2] Replace SpeechRecognitionPhraseList with sequence --- index.bs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/index.bs b/index.bs index 55e6c8c..b05aef0 100644 --- a/index.bs +++ b/index.bs @@ -163,7 +163,7 @@ The term "interim result" indicates a {{SpeechRecognitionResult}} in which the {
: [[phrases]] :: - A sequence of {{SpeechRecognitionPhrase}} representing a list of phrases for contextual biasing. The initial value is an empty sequence. + An {{ObservableArray}} of {{SpeechRecognitionPhrase}} objects representing a list of phrases for contextual biasing. The initial value is a new empty {{ObservableArray}}.
@@ -178,7 +178,7 @@ interface SpeechRecognition : EventTarget { attribute boolean interimResults; attribute unsigned long maxAlternatives; attribute boolean processLocally; - attribute sequence<SpeechRecognitionPhrase> phrases; + attribute ObservableArray<SpeechRecognitionPhrase> phrases; // methods to drive the speech interaction undefined start(); @@ -337,18 +337,11 @@ interface SpeechRecognitionPhrase { <dt><dfn attribute for=SpeechRecognition>phrases</dfn> attribute</dt> <dd> - This attribute represents a list of phrases for contextual biasing. + The `phrases` attribute provides a list of {{SpeechRecognitionPhrase}} objects to be used for contextual biasing. This is an {{ObservableArray}}, which can be modified like a JavaScript `Array` (e.g., using `push()`). </dd> <dd> The getter steps are to return the value of {{SpeechRecognition/[[phrases]]}}. </dd> - <dd> - The setter steps are: - 1. If the size of the given value is greater than 0 and the system does not support contextual biasing, - throw a {{SpeechRecognitionErrorEvent}} with the {{phrases-not-supported}} error code and abort these steps. - 1. Set {{SpeechRecognition/[[phrases]]}} to the given value. - 1. Send a copy of {{SpeechRecognition/[[phrases]]}} to the system for initializing or updating the phrases for contextual biasing implementation. - </dd> </dl> <p class=issue>The group has discussed whether WebRTC might be used to specify selection of audio sources and remote recognizers. @@ -496,6 +489,9 @@ following steps: 1. If {{SpeechRecognition/[[started]]}} is `true` and no <a event for=SpeechRecognition>error</a> event or <a event for=SpeechRecognition>end</a> event has fired on it, throw an {{InvalidStateError}} and abort these steps. +1. If this.{{SpeechRecognition/phrases}}'s `length` is greater than 0 and the user agent does not support contextual biasing: + 1. [=Queue a task=] to [=fire an event=] named <a event for=SpeechRecognition>error</a> at [=this=] using {{SpeechRecognitionErrorEvent}} with its {{SpeechRecognitionErrorEvent/error}} attribute initialized to `phrases-not-supported` and its {{SpeechRecognitionErrorEvent/message}} attribute set to an implementation-defined string detailing the reason. + 1. Abort these steps. 1. If this.{{SpeechRecognition/[[processLocally]]}} is `true`: 1. 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: 1. [=Queue a task=] to [=fire an event=] named <a event for=SpeechRecognition>error</a> at [=this=] using {{SpeechRecognitionErrorEvent}} with its {{SpeechRecognitionErrorEvent/error}} attribute initialized to {{SpeechRecognitionErrorCode/service-not-allowed}} and its {{SpeechRecognitionErrorEvent/message}} attribute set to an implementation-defined string detailing the reason.