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

Unified Diff: chrome/common/extensions/docs/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: correcting a reference to WebRequest as it was used as base template. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/experimental.speechInput.html
diff --git a/chrome/common/extensions/docs/experimental.speechInput.html b/chrome/common/extensions/docs/experimental.speechInput.html
index 5638b28d99abde2b13052732c2fe919588ccbf20..177153e475da6fd90462d2ee8f3dd0aacac7eb2c 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.
@@ -291,16 +291,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>
@@ -435,12 +470,127 @@
<!-- /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. It provides exclusive
+access to the default recording device to the first extension requesting it.
+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 speechInput
+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.
+This will asynchronously request to start a new session for speech recognition.
+If provided, <code>callback</code> will be called once the actual recording has
+successfully started. A microphone tray icon will appear on the task bar during
+all the recognition session. In case of error during the start the call will
+fail and <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 start when the device is
+being used by anything else than the current extension 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 if recording is currently in use call the <code>isRecording</code>
+method. Please note that its result is limited to audio recording within Chrome.</p>
+
+<p>Repeated calls for the same session from the extension currently accessing the
+device will also fail and set the error code to <code>requestInProgress</code>
+or <code>invalidOperation</code> depending on the state of the first request.</p>
+
+
+<h2 id="howToGetResults">How to get speech recognition results</h2>
+<p>To listen for speech recognition results the API provides the function
+<code>chrome.experimental.speechInput.onResult.addListener()</code> with the
+following signature.</p>
+
+<pre>var callback = function(result) { ... };
+
+chrome.experimental.speechInput.onResult.addListener(callback);
+</pre>
+
+<p>The <code>result</code> object contains an array of recognition hypotheses
+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>If there is an error during the recognition process or nothing could be
+recognized the <code>onError</code> event will be generated. To listen for
+recognition-time errors use the
+<code>chrome.experimental.speechInput.onError.addListener()</code> function
+in the same way as with <code>onResult</code>. Recording will automatically
+stop in case on error. It is safe to call <code>start</code> again
+from the error callback.</p>
+
+
+<h2 id="howToStop">How to stop recording</h2>
+<p>If an extension is currently recording for speech input it can request to stop
+anytime by calling the <code>stop</code> method. This will asynchronously
+request to finish the current speech recognition session ignoring any results.
+If provided, <code>callback</code> will be called once recording has
+successfully stopped.</p>
+
+<p>Any errors during the stop process will set
+<code>chrome.extension.lastError</code>. Repeated calls for the same session
+from the extension currently accessing the device will also fail and set the
+error code to <code>requestInProgress</code> or <code>invalidOperation</code>
+depending on the state of the first request.</p>
+
+
+<h2 id="otherFeatures">Other features</h2>
+<p>This API also generates events when sound is detected to start and stop
+during a recording session. To listen to them use the functions
+<code>chrome.experimental.speechInput.onSoundStart()</code> and
+<code>chrome.experimental.speechInput.onSoundEnd()</code>.</p>
+
+
+<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(result.hypotheses[0].utterance);
+}
+
+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">

Powered by Google App Engine
This is Rietveld 408576698