OLD | NEW |
---|---|
(Empty) | |
1 <div id="pageData-name" class="pageData">Speech Input API</div> | |
2 | |
3 <!-- BEGIN AUTHORED CONTENT --> | |
4 <p id="classSummary"> | |
5 The <code>chrome.experimental.speechInput</code> module provides | |
6 one-shot speech recognition to Chrome extensions. It provides exclusive | |
Satish
2011/11/11 22:17:54
The 'It provides exclusive' statement is duplicate
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
7 access to the default recording device to the first extension requesting it. | |
8 This module is still experimental. For information on how to use experimental | |
9 APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. | |
10 </p> | |
11 | |
12 <h2 id="manifest">Manifest</h2> | |
13 <p>You must declare the "experimental" permission in the <a | |
14 href="manifest.html">extension manifest</a> to use the speechInput | |
15 API. | |
16 For example:</p> | |
17 <pre>{ | |
18 "name": "My extension", | |
19 ... | |
20 <b>"permissions": [ | |
21 "experimental" | |
22 ]</b>, | |
23 ... | |
24 }</pre> | |
25 | |
26 <h2 id="howToStart">How to start speech recognition</h2> | |
27 <p>To start recognizing speech an extension must call the <code>start</code> met hod. | |
28 This will asynchronously request to start a new session for speech recognition. | |
Satish
2011/11/11 22:17:54
This line seems unnecessary since you talk about t
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
29 If provided, <code>callback</code> will be called once the actual recording has | |
Satish
2011/11/11 22:17:54
remove 'the actual'
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
30 successfully started. A microphone tray icon will appear on the task bar during | |
Satish
2011/11/11 22:17:54
We probably shouldn't talk about the UI here, just
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
31 all the recognition session. In case of error during the start the call will | |
Satish
2011/11/11 22:17:54
remove 'during the start the call will fail and '
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
32 fail and <code>chrome.extension.lastError</code> will be set.</p> | |
33 | |
34 <p>This API provides exclusive access to the default recording device to the fir st | |
35 extension requesting it. Consequently, any calls to start when the device is | |
Satish
2011/11/11 22:17:54
start -> "<code>start</code>"
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
36 being used by anything else than the current extension will fail and set | |
Satish
2011/11/11 22:17:54
'anything else than the current extension' -> 'ano
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
37 <code>chrome.extension.lastError</code>. The message <code>requestDenied</code> | |
38 will be set if another extension in the same profile is making use of the API, | |
39 otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code> | |
40 or <code>unableToStart</code> will be set depending on the situation.</p> | |
41 | |
42 <p>To check if recording is currently in use call the <code>isRecording</code> | |
Satish
2011/11/11 22:17:54
'in use' -> 'active'
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
43 method. Please note that its result is limited to audio recording within Chrome. </p> | |
Satish
2011/11/11 22:17:54
'its result is limited to' -> 'it only checks for'
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
44 | |
45 <p>Repeated calls for the same session from the extension currently accessing th e | |
Satish
2011/11/11 22:17:54
this paragraph seems unnecessary as these are obvi
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
46 device will also fail and set the error code to <code>requestInProgress</code> | |
47 or <code>invalidOperation</code> depending on the state of the first request.</p > | |
48 | |
49 | |
50 <h2 id="howToGetResults">How to get speech recognition results</h2> | |
51 <p>To listen for speech recognition results the API provides the function | |
Satish
2011/11/11 22:17:54
Simplify as 'Listen to the <code>onResult<code> ev
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
52 <code>chrome.experimental.speechInput.onResult.addListener()</code> with the | |
53 following signature.</p> | |
54 | |
55 <pre> | |
56 var callback = function(result) { ... }; | |
57 | |
58 chrome.experimental.speechInput.onResult.addListener(callback); | |
59 </pre> | |
60 | |
61 <p>The <code>result</code> object contains an array of recognition hypotheses | |
62 sorted by decreasing likelihood.</p> | |
63 | |
64 <p>Recording automatically stops when results are received. It is safe to call | |
65 <code>start</code> again from the results callback.</p> | |
66 | |
67 <p>If there is an error during the recognition process or nothing could be | |
Satish
2011/11/11 22:17:54
could simplify as 'To handle errors during speech
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
68 recognized the <code>onError</code> event will be generated. To listen for | |
69 recognition-time errors use the | |
70 <code>chrome.experimental.speechInput.onError.addListener()</code> function | |
71 in the same way as with <code>onResult</code>. Recording will automatically | |
72 stop in case on error. It is safe to call <code>start</code> again | |
73 from the error callback.</p> | |
74 | |
75 | |
76 <h2 id="howToStop">How to stop recording</h2> | |
77 <p>If an extension is currently recording for speech input it can request to sto p | |
Satish
2011/11/11 22:17:54
could simplify as 'To stop speech recognition call
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
78 anytime by calling the <code>stop</code> method. This will asynchronously | |
79 request to finish the current speech recognition session ignoring any results. | |
80 If provided, <code>callback</code> will be called once recording has | |
81 successfully stopped.</p> | |
82 | |
83 <p>Any errors during the stop process will set | |
84 <code>chrome.extension.lastError</code>. Repeated calls for the same session | |
Satish
2011/11/11 22:17:54
could simplify similar to suggested above for star
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
85 from the extension currently accessing the device will also fail and set the | |
86 error code to <code>requestInProgress</code> or <code>invalidOperation</code> | |
87 depending on the state of the first request.</p> | |
88 | |
89 | |
90 <h2 id="otherFeatures">Other features</h2> | |
91 <p>This API also generates events when sound is detected to start and stop | |
Satish
2011/11/11 22:17:54
Perhaps simplify this as just a listing of these t
Leandro Graciá Gil
2011/11/12 14:15:01
Done.
| |
92 during a recording session. To listen to them use the functions | |
93 <code>chrome.experimental.speechInput.onSoundStart()</code> and | |
94 <code>chrome.experimental.speechInput.onSoundEnd()</code>.</p> | |
95 | |
96 | |
97 <h2 id="examples">Examples</h2> | |
98 <p>The following example illustrates how to show a javascript alert with the | |
99 most likely recognition result.</p> | |
100 <pre> | |
101 function checkStart() { | |
102 if (chrome.extension.lastError) { | |
103 alert("Couldn't start speech input: " + chrome.extension.lastError.message); | |
104 } | |
105 } | |
106 | |
107 function recognitionFailed(error) { | |
108 alert("Speech input failed: " + error.code); | |
109 } | |
110 | |
111 function recognitionSucceeded(result) { | |
112 alert(result.hypotheses[0].utterance); | |
113 } | |
114 | |
115 chrome.experimental.speechInput.onError.addListener(recognitionFailed); | |
116 chrome.experimental.speechInput.onResult.addListener(recognitionSucceded); | |
117 chrome.experimental.speechInput.start({ "language": "en" }, checkStart); | |
118 </pre> | |
OLD | NEW |