summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorleandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-18 17:22:53 +0000
committerleandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-18 17:22:53 +0000
commit4a750007d8258df14df7a24c06e1636d941f2301 (patch)
tree1fd7f9d34bc8f73e5c4d8b83f4d897dad81e1d96 /chrome/common
parent98bfef62a20f5cae3c0b145adf6e3209e9cb6b8f (diff)
downloadchromium_src-4a750007d8258df14df7a24c06e1636d941f2301.zip
chromium_src-4a750007d8258df14df7a24c06e1636d941f2301.tar.gz
chromium_src-4a750007d8258df14df7a24c06e1636d941f2301.tar.bz2
Adding static documentation to the speech input extension API.
BUG=97388 TEST=none Review URL: http://codereview.chromium.org/8536022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/extensions/docs/examples/api/speechInput/basic.zipbin0 -> 46654 bytes
-rw-r--r--chrome/common/extensions/docs/examples/api/speechInput/basic/background.html40
-rw-r--r--chrome/common/extensions/docs/examples/api/speechInput/basic/manifest.json16
-rw-r--r--chrome/common/extensions/docs/examples/api/speechInput/basic/start.pngbin0 -> 1113 bytes
-rw-r--r--chrome/common/extensions/docs/examples/api/speechInput/basic/stop.pngbin0 -> 195 bytes
-rw-r--r--chrome/common/extensions/docs/experimental.speechInput.html157
-rw-r--r--chrome/common/extensions/docs/samples.html57
-rw-r--r--chrome/common/extensions/docs/samples.json31
-rw-r--r--chrome/common/extensions/docs/static/experimental.speechInput.html112
9 files changed, 406 insertions, 7 deletions
diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic.zip b/chrome/common/extensions/docs/examples/api/speechInput/basic.zip
new file mode 100644
index 0000000..8c30190
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/speechInput/basic.zip
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic/background.html b/chrome/common/extensions/docs/examples/api/speechInput/basic/background.html
new file mode 100644
index 0000000..34e7151
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/speechInput/basic/background.html
@@ -0,0 +1,40 @@
+<html>
+<script>
+function setStartIcon() {
+ chrome.browserAction.setIcon({ path: "start.png" });
+}
+
+function setStopIcon() {
+ chrome.browserAction.setIcon({ path: "stop.png" });
+}
+
+chrome.browserAction.onClicked.addListener(function(tab) {
+ chrome.experimental.speechInput.isRecording(function(recording) {
+ if (!recording) {
+ chrome.experimental.speechInput.start({}, function() {
+ if (chrome.extension.lastError) {
+ alert("Couldn't start speech input: " + chrome.extension.lastError.message);
+ setStartIcon();
+ } else {
+ setStopIcon();
+ }
+ });
+ } else {
+ chrome.experimental.speechInput.stop(function() {
+ setStartIcon();
+ });
+ }
+ });
+});
+
+chrome.experimental.speechInput.onError.addListener(function(error) {
+ alert("Speech input failed: " + error.code);
+ setStartIcon();
+});
+
+chrome.experimental.speechInput.onResult.addListener(function(result) {
+ alert(result.hypotheses[0].utterance);
+ setStartIcon();
+});
+</script>
+</html>
diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic/manifest.json b/chrome/common/extensions/docs/examples/api/speechInput/basic/manifest.json
new file mode 100644
index 0000000..f9a321c
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/speechInput/basic/manifest.json
@@ -0,0 +1,16 @@
+{
+ "name": "Speech Recognizer",
+ "version": "1.0",
+ "description": "Recognizes your speech and tells you the most likely result.",
+
+ "browser_action": {
+ "default_title": "Speech Recognizer",
+ "default_icon": "start.png"
+ },
+
+ "background_page": "background.html",
+
+ "permissions": [
+ "experimental"
+ ]
+}
diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic/start.png b/chrome/common/extensions/docs/examples/api/speechInput/basic/start.png
new file mode 100644
index 0000000..9efb1e2
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/speechInput/basic/start.png
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic/stop.png b/chrome/common/extensions/docs/examples/api/speechInput/basic/stop.png
new file mode 100644
index 0000000..5318c1c
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/speechInput/basic/stop.png
Binary files differ
diff --git a/chrome/common/extensions/docs/experimental.speechInput.html b/chrome/common/extensions/docs/experimental.speechInput.html
index 1e51b18..2c5727a 100644
--- a/chrome/common/extensions/docs/experimental.speechInput.html
+++ b/chrome/common/extensions/docs/experimental.speechInput.html
@@ -16,7 +16,7 @@
<script type="text/javascript" src="js/api_page_generator.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/sidebar.js"></script>
- <title>chrome.experimental.speechInput - Google Chrome Extensions - Google Code</title></head>
+ <title>Speech Input API - Google Chrome Extensions - Google Code</title></head>
<body> <div id="gc-container" class="labs">
<div id="devModeWarning">
You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files.
@@ -294,16 +294,51 @@
<div class="g-unit" id="gc-pagecontent">
<div id="pageTitle">
- <h1 class="page_title">chrome.experimental.speechInput</h1>
+ <h1 class="page_title">Speech Input API</h1>
</div>
<!-- TABLE OF CONTENTS -->
<div id="toc">
<h2>Contents</h2>
<ol>
- <li style="display: none; ">
- <a>h2Name</a>
+ <li>
+ <a href="#manifest">Manifest</a>
<ol>
- <li>
+ <li style="display: none; ">
+ <a>h3Name</a>
+ </li>
+ </ol>
+ </li><li>
+ <a href="#howToStart">How to start speech recognition</a>
+ <ol>
+ <li style="display: none; ">
+ <a>h3Name</a>
+ </li>
+ </ol>
+ </li><li>
+ <a href="#howToGetResults">How to get speech recognition results</a>
+ <ol>
+ <li style="display: none; ">
+ <a>h3Name</a>
+ </li>
+ </ol>
+ </li><li>
+ <a href="#howToStop">How to stop recording</a>
+ <ol>
+ <li style="display: none; ">
+ <a>h3Name</a>
+ </li>
+ </ol>
+ </li><li>
+ <a href="#otherFeatures">Other features</a>
+ <ol>
+ <li style="display: none; ">
+ <a>h3Name</a>
+ </li>
+ </ol>
+ </li><li>
+ <a href="#examples">Examples</a>
+ <ol>
+ <li style="display: none; ">
<a>h3Name</a>
</li>
</ol>
@@ -438,12 +473,120 @@
<!-- /TABLE OF CONTENTS -->
<!-- Standard content lead-in for experimental API pages -->
- <p id="classSummary">
+ <p id="classSummary" style="display: none; ">
For information on how to use experimental APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
</p>
<!-- STATIC CONTENT PLACEHOLDER -->
- <div id="static"></div>
+ <div id="static"><div id="pageData-name" class="pageData">Speech Input API</div>
+
+<!-- BEGIN AUTHORED CONTENT -->
+<p id="classSummary">
+The <code>chrome.experimental.speechInput</code> module provides
+one-shot speech recognition to Chrome extensions.
+This module is still experimental. For information on how to use experimental
+APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
+</p>
+
+<h2 id="manifest">Manifest</h2>
+<p>You must declare the "experimental" permission in the <a href="manifest.html">extension manifest</a> to use the speech input
+API.
+For example:</p>
+<pre>{
+ "name": "My extension",
+ ...
+ <b>"permissions": [
+ "experimental"
+ ]</b>,
+ ...
+}</pre>
+
+<h2 id="howToStart">How to start speech recognition</h2>
+<p>To start recognizing speech an extension must call the <code>start()</code>
+method. If provided, your callback will be called once recording has
+successfully started. In case of error <code>chrome.extension.lastError</code>
+will be set.</p>
+
+<p>This API provides exclusive access to the default recording device to the
+first extension requesting it. Consequently, any calls to <code>start()</code>
+when the device is being used by another extension or web page will fail and set
+<code>chrome.extension.lastError</code>. The message <code>requestDenied</code>
+will be set if another extension in the same profile is making use of the API.
+Otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code>
+or <code>unableToStart</code> will be set depending on the situation.</p>
+
+<p>To check whether recording is currently active, call the
+<code>isRecording()</code> method. Please note that it only checks for audio
+recording within Chrome.</p>
+
+
+<h2 id="howToGetResults">How to get speech recognition results</h2>
+<p>Listen to the <code>onResult</code> event to receive speech recognition
+results.</p>
+
+<pre>var callback = function(result) { ... };
+
+chrome.experimental.speechInput.onResult.addListener(callback);
+</pre>
+
+<p>The <code>result</code> object contains an array of
+<a href="#type-SpeechInputResultHypothesis">SpeechInputResultHypothesis</a>
+sorted by decreasing likelihood.</p>
+
+<p>Recording automatically stops when results are received. It is safe to call
+<code>start()</code> again from the results callback.</p>
+
+<p>To handle errors during speech recognition listen for the
+<code>onError</code> event.</p>
+
+<pre>var callback = function(error) { ... };
+
+chrome.experimental.speechInput.onError.addListener(callback);
+</pre>
+
+<p></p>Recording will automatically stop in case of error.
+It is safe to call <code>start()</code> again from the error callback.<p></p>
+
+
+<h2 id="howToStop">How to stop recording</h2>
+<p>To stop speech recognition call the <code>stop()</code> method. If provided,
+the callback function will be called once recording has successfully stopped.
+In case of error <code>chrome.extension.lastError</code> will be set.
+</p>
+
+
+<h2 id="otherFeatures">Other features</h2>
+<ul><li>
+<code>onSoundStart</code> - Event generated when start of sound is detected
+(from previously being silent).
+</li><li>
+<code>onSoundEnd</code> - Event generated when end of sound is detected (a
+continued period of silence).
+</li></ul>
+
+
+<h2 id="examples">Examples</h2>
+<p>The following example illustrates how to show a JavaScript alert with the
+most likely recognition result.</p>
+<pre>function checkStart() {
+ if (chrome.extension.lastError) {
+ alert("Couldn't start speech input: " + chrome.extension.lastError.message);
+ }
+}
+
+function recognitionFailed(error) {
+ alert("Speech input failed: " + error.code);
+}
+
+function recognitionSucceeded(result) {
+ alert("Recognized '" + result.hypotheses[0].utterance + "' with confidence " + result.hypotheses[0].confidence);
+}
+
+chrome.experimental.speechInput.onError.addListener(recognitionFailed);
+chrome.experimental.speechInput.onResult.addListener(recognitionSucceded);
+chrome.experimental.speechInput.start({ "language": "en" }, checkStart);
+</pre>
+</div>
<!-- API PAGE -->
<div class="apiPage">
diff --git a/chrome/common/extensions/docs/samples.html b/chrome/common/extensions/docs/samples.html
index eb16818..8a9e8db0 100644
--- a/chrome/common/extensions/docs/samples.html
+++ b/chrome/common/extensions/docs/samples.html
@@ -384,6 +384,7 @@
"38f6e1e17756ede38b1364c7114a738ca717dcbb": "SANDWICHBAR SHOWS AN INFOBAR ON PAGES WHICH CONTAIN THE WORD SANDWICH BACKGROUND_PAGE EXPERIMENTAL CHROME.EXPERIMENTAL.INFOBARS.SHOW CHROME.EXTENSION.ONREQUEST CHROME.EXTENSION.SENDREQUEST",
"fc89b35755483af30b66cd72cefa34a43a3e8312": "SHOW TABS IN PROCESS ADDS A BROWSER ACTION SHOWING WHICH TABS SHARE THE CURRENT TABS PROCESS. BROWSER_ACTION EXPERIMENTAL POPUP TABS CHROME.TABS.GET CHROME.TABS.GETSELECTED CHROME.TABS.UPDATE CHROME.WINDOWS.GET CHROME.WINDOWS.GETALL CHROME.WINDOWS.GETCURRENT CHROME.WINDOWS.UPDATE",
"a491a2faa1fe79cb49b2fe9ed2720f4723c14184": "SPEAK SELECTION SPEAKS THE CURRENT SELECTION OUT LOUD. <ALL_URLS> BACKGROUND_PAGE BROWSER_ACTION OPTIONS_PAGE TABS TTS CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETICON CHROME.EXTENSION.GETURL CHROME.EXTENSION.ONREQUEST CHROME.EXTENSION.SENDREQUEST CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TABS.SENDREQUEST CHROME.TTS.GETVOICES CHROME.TTS.SPEAK CHROME.TTS.STOP CHROME.WINDOWS.GET CHROME.WINDOWS.GETALL",
+ "a942b7626644674b7a56678930d054497b244ee7": "SPEECH RECOGNIZER RECOGNIZES YOUR SPEECH AND TELLS YOU THE MOST LIKELY RESULT. BACKGROUND_PAGE BROWSER_ACTION EXPERIMENTAL CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETICON CHROME.EXPERIMENTAL.SPEECHINPUT.ISRECORDING CHROME.EXPERIMENTAL.SPEECHINPUT.ONERROR CHROME.EXPERIMENTAL.SPEECHINPUT.ONRESULT CHROME.EXPERIMENTAL.SPEECHINPUT.START CHROME.EXPERIMENTAL.SPEECHINPUT.STOP",
"230463f2d5c3d4d0ca13c230e1f00f2aae0a8a64": "TAB INSPECTOR UTILITY FOR WORKING WITH THE EXTENSION TABS API BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.ONCLICKED CHROME.EXTENSION.GETURL CHROME.TABS.CREATE CHROME.TABS.GET CHROME.TABS.GETALLINWINDOW CHROME.TABS.GETSELECTED CHROME.TABS.MOVE CHROME.TABS.ONATTACHED CHROME.TABS.ONCREATED CHROME.TABS.ONDETACHED CHROME.TABS.ONMOVED CHROME.TABS.ONREMOVED CHROME.TABS.ONSELECTIONCHANGED CHROME.TABS.ONUPDATED CHROME.TABS.REMOVE CHROME.TABS.UPDATE CHROME.WINDOWS.CREATE CHROME.WINDOWS.GET CHROME.WINDOWS.GETALL CHROME.WINDOWS.GETCURRENT CHROME.WINDOWS.GETLASTFOCUSED CHROME.WINDOWS.ONCREATED CHROME.WINDOWS.ONFOCUSCHANGED CHROME.WINDOWS.ONREMOVED CHROME.WINDOWS.REMOVE CHROME.WINDOWS.UPDATE",
"04f5d2ddea95746b0200be1ea223ccb7a748a771": "TALKING ALARM CLOCK A CLOCK WITH TWO CONFIGURABLE ALARMS THAT WILL PLAY A SOUND AND SPEAK A PHRASE OF YOUR CHOICE. BACKGROUND BACKGROUND_PAGE BROWSER_ACTION TTS CHROME.BROWSERACTION.SETICON CHROME.EXTENSION.CONNECT CHROME.EXTENSION.ONCONNECT CHROME.TTS.GETVOICES CHROME.TTS.SPEAK CHROME.TTS.STOP",
"e1697cacebad05218798bf3e8a0f724517f0e8c3": "TEST SCREENSHOT EXTENSION DEMONSTRATE SCREENSHOT FUNCTIONALITY IN THE CHROME.TABS API. NOTE: ONLY WORKS FOR CODE.GOOGLE.COM BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.ONCLICKED CHROME.EXTENSION.GETURL CHROME.EXTENSION.GETVIEWS CHROME.TABS.CAPTUREVISIBLETAB CHROME.TABS.CREATE CHROME.TABS.ONUPDATED",
@@ -3792,6 +3793,62 @@
- <a>Install extension</a>
</span>
</div>
+</div><div class="sample" id="a942b7626644674b7a56678930d054497b244ee7">
+ <img class="icon" style="display: none; ">
+ <img class="icon" src="images/sample-default-icon.png">
+ <h2 class="name">
+ <a href="#a942b7626644674b7a56678930d054497b244ee7">Speech Recognizer</a>
+ <span style="display: none; ">(packaged app)</span>
+ </h2>
+ <p class="metadata features">Uses
+ <span>
+ <strong>background_page</strong><span>, </span>
+ <span style="display: none; "> and</span>
+ </span><span>
+ <strong>browser_action</strong><span style="display: none; ">, </span>
+ <span> and</span>
+ </span><span>
+ <strong>experimental</strong><span style="display: none; ">, </span>
+ <span style="display: none; "> and</span>
+ </span>
+ </p>
+ <p>Recognizes your speech and tells you the most likely result.</p>
+ <div class="apicalls"><strong>Calls:</strong>
+ <ul>
+ <li>
+ <code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
+ </li><li>
+ <code><a href="browserAction.html#method-setIcon">chrome.browserAction.setIcon</a></code>
+ </li><li>
+ <code><a href="experimental.speechInput.html#method-isRecording">chrome.experimental.speechInput.isRecording</a></code>
+ </li><li>
+ <code><a href="experimental.speechInput.html#event-onError">chrome.experimental.speechInput.onError</a></code>
+ </li><li>
+ <code><a href="experimental.speechInput.html#event-onResult">chrome.experimental.speechInput.onResult</a></code>
+ </li><li>
+ <code><a href="experimental.speechInput.html#method-start">chrome.experimental.speechInput.start</a></code>
+ </li><li>
+ <code><a href="experimental.speechInput.html#method-stop">chrome.experimental.speechInput.stop</a></code>
+ </li>
+ </ul>
+ </div>
+ <div class="sourcefiles"><strong>Source files:</strong>
+ <ul>
+ <li>
+ <code><a target="_blank" href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/speechInput/basic/background.html?content-type=text/plain">background.html</a></code>
+ </li><li>
+ <code><a target="_blank" href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/speechInput/basic/manifest.json?content-type=text/plain">manifest.json</a></code>
+ </li>
+ </ul>
+ </div>
+ <div>
+ <a target="_blank" href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/speechInput/basic/">Browse source</a>
+ - <a href="examples/api/speechInput/basic.zip">Download source</a>
+ <!-- Only show the Install CRX link if a CRX file is provided -->
+ <span style="display: none; ">
+ - <a>Install extension</a>
+ </span>
+ </div>
</div><div class="sample" id="230463f2d5c3d4d0ca13c230e1f00f2aae0a8a64">
<img class="icon" style="display: none; ">
<img class="icon" src="images/sample-default-icon.png">
diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json
index 18e6cd1..dd45316 100644
--- a/chrome/common/extensions/docs/samples.json
+++ b/chrome/common/extensions/docs/samples.json
@@ -2095,6 +2095,37 @@
{
"api_calls": [
"chrome.browserAction.onClicked",
+ "chrome.browserAction.setIcon",
+ "chrome.experimental.speechInput.isRecording",
+ "chrome.experimental.speechInput.onError",
+ "chrome.experimental.speechInput.onResult",
+ "chrome.experimental.speechInput.start",
+ "chrome.experimental.speechInput.stop"
+ ],
+ "crx_path": null,
+ "description": "Recognizes your speech and tells you the most likely result.",
+ "features": [
+ "background_page",
+ "browser_action",
+ "experimental"
+ ],
+ "icon": null,
+ "id": "a942b7626644674b7a56678930d054497b244ee7",
+ "name": "Speech Recognizer",
+ "packaged_app": false,
+ "path": "examples\/api\/speechInput\/basic\/",
+ "protocols": [],
+ "search_string": "SPEECH RECOGNIZER RECOGNIZES YOUR SPEECH AND TELLS YOU THE MOST LIKELY RESULT. BACKGROUND_PAGE BROWSER_ACTION EXPERIMENTAL CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETICON CHROME.EXPERIMENTAL.SPEECHINPUT.ISRECORDING CHROME.EXPERIMENTAL.SPEECHINPUT.ONERROR CHROME.EXPERIMENTAL.SPEECHINPUT.ONRESULT CHROME.EXPERIMENTAL.SPEECHINPUT.START CHROME.EXPERIMENTAL.SPEECHINPUT.STOP",
+ "source_files": [
+ "background.html",
+ "manifest.json"
+ ],
+ "source_hash": "b092b58c922e769c003eb83e6ef4a63557ddc7f2",
+ "zip_path": "examples\/api\/speechInput\/basic.zip"
+ },
+ {
+ "api_calls": [
+ "chrome.browserAction.onClicked",
"chrome.extension.getURL",
"chrome.tabs.create",
"chrome.tabs.get",
diff --git a/chrome/common/extensions/docs/static/experimental.speechInput.html b/chrome/common/extensions/docs/static/experimental.speechInput.html
new file mode 100644
index 0000000..b3c439c
--- /dev/null
+++ b/chrome/common/extensions/docs/static/experimental.speechInput.html
@@ -0,0 +1,112 @@
+<div id="pageData-name" class="pageData">Speech Input API</div>
+
+<!-- BEGIN AUTHORED CONTENT -->
+<p id="classSummary">
+The <code>chrome.experimental.speechInput</code> module provides
+one-shot speech recognition to Chrome extensions.
+This module is still experimental. For information on how to use experimental
+APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
+</p>
+
+<h2 id="manifest">Manifest</h2>
+<p>You must declare the "experimental" permission in the <a
+ href="manifest.html">extension manifest</a> to use the speech input
+API.
+For example:</p>
+<pre>{
+ "name": "My extension",
+ ...
+ <b>"permissions": [
+ "experimental"
+ ]</b>,
+ ...
+}</pre>
+
+<h2 id="howToStart">How to start speech recognition</h2>
+<p>To start recognizing speech an extension must call the <code>start()</code>
+method. If provided, your callback will be called once recording has
+successfully started. In case of error <code>chrome.extension.lastError</code>
+will be set.</p>
+
+<p>This API provides exclusive access to the default recording device to the
+first extension requesting it. Consequently, any calls to <code>start()</code>
+when the device is being used by another extension or web page will fail and set
+<code>chrome.extension.lastError</code>. The message <code>requestDenied</code>
+will be set if another extension in the same profile is making use of the API.
+Otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code>
+or <code>unableToStart</code> will be set depending on the situation.</p>
+
+<p>To check whether recording is currently active, call the
+<code>isRecording()</code> method. Please note that it only checks for audio
+recording within Chrome.</p>
+
+
+<h2 id="howToGetResults">How to get speech recognition results</h2>
+<p>Listen to the <code>onResult</code> event to receive speech recognition
+results.</p>
+
+<pre>
+var callback = function(result) { ... };
+
+chrome.experimental.speechInput.onResult.addListener(callback);
+</pre>
+
+<p>The <code>result</code> object contains an array of
+<a href="#type-SpeechInputResultHypothesis">SpeechInputResultHypothesis</a>
+sorted by decreasing likelihood.</p>
+
+<p>Recording automatically stops when results are received. It is safe to call
+<code>start()</code> again from the results callback.</p>
+
+<p>To handle errors during speech recognition listen for the
+<code>onError</code> event.</p>
+
+<pre>
+var callback = function(error) { ... };
+
+chrome.experimental.speechInput.onError.addListener(callback);
+</pre>
+
+</p>Recording will automatically stop in case of error.
+It is safe to call <code>start()</code> again from the error callback.</p>
+
+
+<h2 id="howToStop">How to stop recording</h2>
+<p>To stop speech recognition call the <code>stop()</code> method. If provided,
+the callback function will be called once recording has successfully stopped.
+In case of error <code>chrome.extension.lastError</code> will be set.
+</p>
+
+
+<h2 id="otherFeatures">Other features</h2>
+<ul><li>
+<code>onSoundStart</code> - Event generated when start of sound is detected
+(from previously being silent).
+</li><li>
+<code>onSoundEnd</code> - Event generated when end of sound is detected (a
+continued period of silence).
+</li></ul>
+
+
+<h2 id="examples">Examples</h2>
+<p>The following example illustrates how to show a JavaScript alert with the
+most likely recognition result.</p>
+<pre>
+function checkStart() {
+ if (chrome.extension.lastError) {
+ alert("Couldn't start speech input: " + chrome.extension.lastError.message);
+ }
+}
+
+function recognitionFailed(error) {
+ alert("Speech input failed: " + error.code);
+}
+
+function recognitionSucceeded(result) {
+ alert("Recognized '" + result.hypotheses[0].utterance + "' with confidence " + result.hypotheses[0].confidence);
+}
+
+chrome.experimental.speechInput.onError.addListener(recognitionFailed);
+chrome.experimental.speechInput.onResult.addListener(recognitionSucceded);
+chrome.experimental.speechInput.start({ "language": "en" }, checkStart);
+</pre>