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

Side by Side Diff: chrome/common/extensions/docs/server2/templates/private/experimental_speechInput_intro.html

Issue 10750017: Extensions Docs Server: Intro data source (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years, 5 months 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
OLDNEW
(Empty)
1 <!-- BEGIN AUTHORED CONTENT -->
2 <p id="classSummary">
3 The <code>chrome.experimental.speechInput</code> module provides
4 one-shot speech recognition to Chrome extensions.
5 This module is still experimental. For information on how to use experimental
6 APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
7 </p>
8 <h2 id="manifest">Manifest</h2>
9 <p>You must declare the "experimental" permission in the <a
10 href="manifest.html">extension manifest</a> to use the speech input
11 API.
12 For example:</p>
13 <pre>{
14 "name": "My extension",
15 ...
16 <b>"permissions": [
17 "experimental"
18 ]</b>,
19 ...
20 }</pre>
21 <h2 id="howToStart">How to start speech recognition</h2>
22 <p>To start recognizing speech an extension must call the <code>start()</code>
23 method. If provided, your callback will be called once recording has
24 successfully started. In case of error <code>chrome.extension.lastError</code>
25 will be set.</p>
26 <p>This API provides exclusive access to the default recording device to the
27 first extension requesting it. Consequently, any calls to <code>start()</code>
28 when the device is being used by another extension or web page will fail and set
29 <code>chrome.extension.lastError</code>. The message <code>requestDenied</code>
30 will be set if another extension in the same profile is making use of the API.
31 Otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code>
32 or <code>unableToStart</code> will be set depending on the situation.</p>
33 <p>To check whether recording is currently active, call the
34 <code>isRecording()</code> method. Please note that it only checks for audio
35 recording within Chrome.</p>
36 <h2 id="howToGetResults">How to get speech recognition results</h2>
37 <p>Listen to the <code>onResult</code> event to receive speech recognition
38 results.</p>
39 <pre>
40 var callback = function(result) { ... };
41 chrome.experimental.speechInput.onResult.addListener(callback);
42 </pre>
43 <p>The <code>result</code> object contains an array of
44 <a href="#type-experimental.speechinput.SpeechInputResultHypothesis">SpeechInput ResultHypothesis</a>
45 sorted by decreasing likelihood.</p>
46 <p>Recording automatically stops when results are received. It is safe to call
47 <code>start()</code> again from the results callback.</p>
48 <p>To handle errors during speech recognition listen for the
49 <code>onError</code> event.</p>
50 <pre>
51 var callback = function(error) { ... };
52 chrome.experimental.speechInput.onError.addListener(callback);
53 </pre>
54 </p>Recording will automatically stop in case of error.
55 It is safe to call <code>start()</code> again from the error callback.</p>
56 <h2 id="howToStop">How to stop recording</h2>
57 <p>To stop speech recognition call the <code>stop()</code> method. If provided,
58 the callback function will be called once recording has successfully stopped.
59 In case of error <code>chrome.extension.lastError</code> will be set.
60 </p>
61 <h2 id="otherFeatures">Other features</h2>
62 <ul><li>
63 <code>onSoundStart</code> - Event generated when start of sound is detected
64 (from previously being silent).
65 </li><li>
66 <code>onSoundEnd</code> - Event generated when end of sound is detected (a
67 continued period of silence).
68 </li></ul>
69 <h2 id="examples">Examples</h2>
70 <p>The following example illustrates how to show a JavaScript alert with the
71 most likely recognition result.</p>
72 <pre>
73 function checkStart() {
74 if (chrome.extension.lastError) {
75 alert("Couldn't start speech input: " + chrome.extension.lastError.message);
76 }
77 }
78 function recognitionFailed(error) {
79 alert("Speech input failed: " + error.code);
80 }
81 function recognitionSucceeded(result) {
82 alert("Recognized '" + result.hypotheses[0].utterance + "' with confidence " + result.hypotheses[0].confidence);
83 }
84 chrome.experimental.speechInput.onError.addListener(recognitionFailed);
85 chrome.experimental.speechInput.onResult.addListener(recognitionSucceeded);
86 chrome.experimental.speechInput.start({ "language": "en" }, checkStart);
87 </pre>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698