Skip to content

Commit 4d6e11e

Browse files
Replace SpeechRecognitionPhraseList with an ObservableArray (#169)
* Replace SpeechRecognitionPhraseList with sequence<SpeechRecognitionPhrase> * Replace SpeechRecognitionPhraseList with sequence<SpeechRecognitionPhrase> --------- Co-authored-by: Evan Liu <[email protected]>
1 parent 5166682 commit 4d6e11e

File tree

1 file changed

+6
-73
lines changed

1 file changed

+6
-73
lines changed

index.bs

Lines changed: 6 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ The term "interim result" indicates a {{SpeechRecognitionResult}} in which the {
163163
<dl dfn-type=attribute dfn-for="SpeechRecognition">
164164
: <dfn>[[phrases]]</dfn>
165165
::
166-
A {{SpeechRecognitionPhraseList}} representing a list of phrases for contextual biasing. The initial value is null.
166+
An {{ObservableArray}} of {{SpeechRecognitionPhrase}} objects representing a list of phrases for contextual biasing. The initial value is a new empty {{ObservableArray}}.
167167
</dl>
168168

169169
<xmp class="idl">
@@ -178,7 +178,7 @@ interface SpeechRecognition : EventTarget {
178178
attribute boolean interimResults;
179179
attribute unsigned long maxAlternatives;
180180
attribute boolean processLocally;
181-
attribute SpeechRecognitionPhraseList phrases;
181+
attribute ObservableArray<SpeechRecognitionPhrase> phrases;
182182

183183
// methods to drive the speech interaction
184184
undefined start();
@@ -298,16 +298,6 @@ interface SpeechRecognitionPhrase {
298298
readonly attribute DOMString phrase;
299299
readonly attribute float boost;
300300
};
301-
302-
// The object representing a list of phrases for contextual biasing.
303-
[SecureContext, Exposed=Window]
304-
interface SpeechRecognitionPhraseList {
305-
constructor(sequence<SpeechRecognitionPhrase> phrases);
306-
readonly attribute unsigned long length;
307-
SpeechRecognitionPhrase item(unsigned long index);
308-
undefined addItem(SpeechRecognitionPhrase item);
309-
undefined removeItem(unsigned long index);
310-
};
311301
</xmp>
312302

313303
<h4 id="speechreco-attributes">SpeechRecognition Attributes</h4>
@@ -347,18 +337,11 @@ interface SpeechRecognitionPhraseList {
347337

348338
<dt><dfn attribute for=SpeechRecognition>phrases</dfn> attribute</dt>
349339
<dd>
350-
This attribute represents a list of phrases for contextual biasing.
340+
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()`).
351341
</dd>
352342
<dd>
353343
The getter steps are to return the value of {{SpeechRecognition/[[phrases]]}}.
354344
</dd>
355-
<dd>
356-
The setter steps are:
357-
1. If the {{SpeechRecognitionPhraseList/length}} of the given value is greater than 0 and the system does not support contextual biasing,
358-
throw a {{SpeechRecognitionErrorEvent}} with the {{phrases-not-supported}} error code and abort these steps.
359-
1. Set {{SpeechRecognition/[[phrases]]}} to the given value.
360-
1. Send a copy of {{SpeechRecognition/[[phrases]]}} to the system for initializing or updating the phrases for contextual biasing implementation.
361-
</dd>
362345
</dl>
363346

364347
<p class=issue>The group has discussed whether WebRTC might be used to specify selection of audio sources and remote recognizers.
@@ -506,6 +489,9 @@ following steps:
506489
1. If {{SpeechRecognition/[[started]]}} is `true` and no <a event
507490
for=SpeechRecognition>error</a> event or <a event for=SpeechRecognition>end</a> event
508491
has fired on it, throw an {{InvalidStateError}} and abort these steps.
492+
1. If this.{{SpeechRecognition/phrases}}'s `length` is greater than 0 and the user agent does not support contextual biasing:
493+
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.
494+
1. Abort these steps.
509495
1. If this.{{SpeechRecognition/[[processLocally]]}} is `true`:
510496
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:
511497
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.
@@ -728,59 +714,6 @@ For a non-continuous recognition it will hold only a single value.</p>
728714
<dd>This attribute returns the value of {{[[boost]]}}.</dd>
729715
</dl>
730716

731-
<h4 id="speechreco-phraselist">SpeechRecognitionPhraseList</h4>
732-
733-
<p>The SpeechRecognitionPhraseList object holds a list of phrases for contextual biasing and has the following internal slot:</p>
734-
735-
<dl dfn-type=attribute dfn-for="SpeechRecognitionPhraseList">
736-
: <dfn>[[phrases]]</dfn>
737-
::
738-
A list of {{SpeechRecognitionPhrase}} representing the phrases to be boosted. The initial value is an empty list.
739-
</dl>
740-
741-
<dl>
742-
<dt><dfn constructor for=SpeechRecognitionPhraseList>SpeechRecognitionPhraseList(|phrases|)</dfn> constructor</dt>
743-
<dd>
744-
When this constructor is invoked, run the following steps:
745-
1. Let |list| be a new object of type {{SpeechRecognitionPhraseList}}.
746-
1. Set |list|.{{SpeechRecognitionPhraseList/[[phrases]]}} to be the value of |phrases|.
747-
1. Return |list|.
748-
</dd>
749-
750-
<dt><dfn attribute for=SpeechRecognitionPhraseList>length</dfn> attribute</dt>
751-
<dd>
752-
This attribute indicates the number of phrases in the list.
753-
When invoked, return the number of items in {{SpeechRecognitionPhraseList/[[phrases]]}}.
754-
</dd>
755-
756-
<dt><dfn method for=SpeechRecognitionPhraseList>item(|index|)</dfn> method</dt>
757-
<dd>
758-
This method gets the {{SpeechRecognitionPhrase}} object at the |index| of the list.
759-
When invoked, run the following steps:
760-
1. If |index| is smaller than 0, or greater than or equal to {{SpeechRecognitionPhraseList/length}},
761-
throw a {{RangeError}} and abort these steps.
762-
1. Return the {{SpeechRecognitionPhrase}} at the |index| of {{SpeechRecognitionPhraseList/[[phrases]]}}.
763-
</dd>
764-
765-
<dt><dfn method for=SpeechRecognitionPhraseList>addItem(|item|)</dfn> method</dt>
766-
<dd>
767-
This method adds the {{SpeechRecognitionPhrase}} object |item| to the list.
768-
When invoked, add |item| to the end of {{SpeechRecognitionPhraseList/[[phrases]]}}.
769-
The list is allowed to have multiple {{SpeechRecognitionPhrase}} objects with the same {{SpeechRecognitionPhrase/[[phrase]]}} value,
770-
and the speech recognition model should use the last {{SpeechRecognitionPhrase/[[boost]]}} value
771-
for this {{SpeechRecognitionPhrase/[[phrase]]}} in the list.
772-
</dd>
773-
774-
<dt><dfn method for=SpeechRecognitionPhraseList>removeItem(|index|)</dfn> method</dt>
775-
<dd>
776-
This method removes the {{SpeechRecognitionPhrase}} object at the |index| of the list.
777-
When invoked, run the following steps:
778-
1. If |index| is smaller than 0, or greater than or equal to {{SpeechRecognitionPhraseList/length}},
779-
throw a {{RangeError}} and abort these steps.
780-
1. Remove the {{SpeechRecognitionPhrase}} object at the |index| of {{SpeechRecognitionPhraseList/[[phrases]]}}.
781-
</dd>
782-
</dl>
783-
784717
<h4 id="speechreco-speechgrammar">SpeechGrammar</h4>
785718

786719
<p>The SpeechGrammar object represents a container for a grammar.</p>

0 commit comments

Comments
 (0)