Skip to content

Commit c0694cb

Browse files
authored
Use algorithmic style more (#144)
* Enable various shorthands * Fix lots of markup, typos, describe both start methods consistently
1 parent 6356249 commit c0694cb

1 file changed

Lines changed: 33 additions & 17 deletions

File tree

index.bs

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Former Editor: Hans Wennborg, Google
1616
Abstract: This specification defines a JavaScript API to enable web developers to incorporate speech recognition and synthesis into their web pages.
1717
Abstract: It enables developers to use scripting to generate text-to-speech output and to use speech recognition as an input for forms, continuous dictation and control.
1818
Abstract: The JavaScript API allows web pages to control activation and timing and to handle results and alternatives.
19+
Markup Shorthands:css no, markdown yes, dfn yes
1920
</pre>
2021

2122
<pre class=biblio>
@@ -99,7 +100,7 @@ This does not preclude adding support for this as a future API enhancement, and
99100
User consent can include, for example:
100101
<ul>
101102
<li>User click on a visible speech input element which has an obvious graphical representation showing that it will start speech input.</li>
102-
<li>Accepting a permission prompt shown as the result of a call to <a method for=SpeechRecognition>start()</a>.</li>
103+
<li>Accepting a permission prompt shown as the result of a call to {{SpeechRecognition/start()}}.</li>
103104
<li>Consent previously granted to always allow speech input for this web page.</li>
104105
</ul>
105106
</li>
@@ -286,17 +287,25 @@ See <a href="https://lists.w3.org/Archives/Public/public-speech-api/2012Sep/0072
286287
<dl>
287288
<dt><dfn method for=SpeechRecognition>start()</dfn> method</dt>
288289
<dd>
289-
1. Let <var>requestMicrophonePermission</var> to <code>true</code>.
290-
1. Run the <a>start session algorithm</a> with <var>requestMicrophonePermission</var>.
290+
Start the speech recognition process, directly from a microphone on the device.
291+
When invoked, run the following steps:
292+
293+
1. Let |requestMicrophonePermission| be a boolan variable set to to `true`.
294+
1. Run the [=start session algorithm=] with |requestMicrophonePermission|.
291295
</dd>
292296

293297
<dt><dfn method for=SpeechRecognition>start({{MediaStreamTrack}} audioTrack)</dfn> method</dt>
294298
<dd>
295-
1. Let <var>audioTrack</var> be the first argument.
296-
1. If <var>audioTrack</var>'s {{MediaStreamTrack/kind}} attribute is NOT <code>"audio"</code>, throw an {{InvalidStateError}} and abort these steps.
297-
1. If <var>audioTrack</var>'s {{MediaStreamTrack/readyState}} attribute is NOT <code>"live"</code>, throw an {{InvalidStateError}} and abort these steps.
298-
1. Let <var>requestMicrophonePermission</var> be <code>false</code>.
299-
1. Run the <a>start session algorithm</a> with <var>requestMicrophonePermission</var>.
299+
Start the speech recognition process, using a {{MediaStreamTrack}}
300+
When invoked, run the following steps:
301+
302+
1. Let |audioTrack| be the first argument.
303+
1. If |audioTrack|'s {{MediaStreamTrack/kind}} attribute is NOT `"audio"`,
304+
throw an {{InvalidStateError}} and abort these steps.
305+
1. If |audioTrack|'s {{MediaStreamTrack/readyState}} attribute is NOT
306+
`"live"`, throw an {{InvalidStateError}} and abort these steps.
307+
1. Let |requestMicrophonePermission| be `false`.
308+
1. Run the [=start session algorithm=] with |requestMicrophonePermission|.
300309
</dd>
301310

302311
<dt><dfn method for=SpeechRecognition>stop()</dfn> method</dt>
@@ -321,15 +330,22 @@ See <a href="https://lists.w3.org/Archives/Public/public-speech-api/2012Sep/0072
321330

322331
</dl>
323332

324-
<p>When the <dfn>start session algorithm</dfn> with <var>requestMicrophonePermission</var> is invoked, the user agent MUST run the following steps:
325-
326-
1. If the [=current settings object=]'s [=relevant global object=]'s [=associated Document=] is NOT [=fully active=], throw an {{InvalidStateError}} and abort these steps.
327-
1. If {{[[started]]}} is <code>true</code> and no <a event for=SpeechRecognition>error</a> or <a event for=SpeechRecognition>end</a> event has fired, throw an {{InvalidStateError}} and abort these steps.
328-
1. Set {{[[started]]}} to <code>true</code>.
329-
1. If <var>requestMicrophonePermission</var> is <code>true</code> and [=request permission to use=] "<code>microphone</code>" is [=permission/"denied"=], abort these steps.
330-
1. Once the system is successfully listening to the recognition, [=fire an event=] named <a event for=SpeechRecognition>start</a> at [=this=].
331-
332-
</p>
333+
When the <dfn>start session algorithm</dfn> with
334+
|requestMicrophonePermission| is invoked, the user agent MUST run the
335+
following steps:
336+
337+
1. If the [=current settings object=]'s [=relevant global object=]'s
338+
[=associated Document=] is NOT [=fully active=], throw an {{InvalidStateError}}
339+
and abort these steps.
340+
1. If {{[[started]]}} is `true` and no <a event
341+
for=SpeechRecognition>error</a> or <a event for=SpeechRecognition>end</a> event
342+
have fired, throw an {{InvalidStateError}} and abort these steps.
343+
1. Set {{[[started]]}} to `true`.
344+
1. If |requestMicrophonePermission| is `true` and [=request
345+
permission to use=] "`microphone`" is [=permission/"denied"=], abort
346+
these steps.
347+
1. Once the system is successfully listening to the recognition, queue a task to
348+
[=fire an event=] named <a event for=SpeechRecognition>start</a> at [=this=].
333349

334350
<h4 id="speechreco-events">SpeechRecognition Events</h4>
335351

0 commit comments

Comments
 (0)