Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: chrome/common/extensions/docs/static/experimental.speechInput.html

Issue 8536022: Adding static documentation to the speech input extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fixes Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/docs/experimental.speechInput.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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.
7 This module is still experimental. For information on how to use experimental
8 APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
9 </p>
10
11 <h2 id="manifest">Manifest</h2>
12 <p>You must declare the "experimental" permission in the <a
13 href="manifest.html">extension manifest</a> to use the speechInput
14 API.
15 For example:</p>
16 <pre>{
17 "name": "My extension",
18 ...
19 <b>"permissions": [
20 "experimental"
21 ]</b>,
22 ...
23 }</pre>
24
25 <h2 id="howToStart">How to start speech recognition</h2>
26 <p>To start recognizing speech an extension must call the <code>start</code>
27 method. If provided, <code>callback</code> will be called once recording has
28 successfully started. In case of error <code>chrome.extension.lastError</code>
29 will be set.</p>
30
31 <p>This API provides exclusive access to the default recording device to the
32 first extension requesting it. Consequently, any calls to <code>start</code>
33 when the device is being used by other extension or web page will fail and set
Satish 2011/11/14 10:22:44 other -> another
Leandro Graciá Gil 2011/11/14 11:25:02 Done.
34 <code>chrome.extension.lastError</code>. The message <code>requestDenied</code>
35 will be set if another extension in the same profile is making use of the API,
36 otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code>
37 or <code>unableToStart</code> will be set depending on the situation.</p>
38
39 <p>To check if recording is currently active use call the <code>isRecording</cod e>
Satish 2011/11/14 10:22:44 use call -> call
Leandro Graciá Gil 2011/11/14 11:25:02 Done.
40 method. Please note that it only checks for audio recording within Chrome.</p>
41
42
43 <h2 id="howToGetResults">How to get speech recognition results</h2>
44 <p>Listen to the <code>onResult</code> event to receive speech recognition
45 results.</p>
46
47 <pre>
48 var callback = function(result) { ... };
49
50 chrome.experimental.speechInput.onResult.addListener(callback);
51 </pre>
52
53 <p>The <code>result</code> object contains an array of recognition hypotheses
Satish 2011/11/14 10:22:44 can you also document in detail this array item (i
Leandro Graciá Gil 2011/11/14 11:25:02 Done.
54 sorted by decreasing likelihood.</p>
55
56 <p>Recording automatically stops when results are received. It is safe to call
57 <code>start</code> again from the results callback.</p>
58
59 <p>To handle errors during speech recognition listen for the
60 <code>onError</code> event.</p>
61
62 <pre>
63 var callback = function(error) { ... };
64
65 chrome.experimental.speechInput.onError.addListener(callback);
66 </pre>
67
68 </p>Recording will automatically stop in case on error.
69 It is safe to call <code>start</code> again from the error callback.</p>
70
71
72 <h2 id="howToStop">How to stop recording</h2>
73 <p>To stop speech recognition call the <code>stop</code> method. If provided,
74 <code>callback</code> will be called once recording has successfully
75 stopped. In case of error <code>chrome.extension.lastError</code> will be set.
76 </p>
77
78
79 <h2 id="otherFeatures">Other features</h2>
80 <ul><li>
81 <code>onSoundStart</code> - Event generated when start of sound is detected
82 (from previously being silent).
83 </li><li>
84 <code>onSoundEnd</code> - Event generated when end of sound is detected (a
85 continued period of silence).
86 </li></ul>
87
88
89 <h2 id="examples">Examples</h2>
90 <p>The following example illustrates how to show a javascript alert with the
91 most likely recognition result.</p>
92 <pre>
93 function checkStart() {
94 if (chrome.extension.lastError) {
95 alert("Couldn't start speech input: " + chrome.extension.lastError.message);
96 }
97 }
98
99 function recognitionFailed(error) {
100 alert("Speech input failed: " + error.code);
101 }
102
103 function recognitionSucceeded(result) {
104 alert(result.hypotheses[0].utterance);
105 }
106
107 chrome.experimental.speechInput.onError.addListener(recognitionFailed);
108 chrome.experimental.speechInput.onResult.addListener(recognitionSucceded);
109 chrome.experimental.speechInput.start({ "language": "en" }, checkStart);
110 </pre>
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/experimental.speechInput.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698