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

Side by Side 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: nit 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
OLDNEW
1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc. Note: 1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc. Note:
2 1) The <head> information in this page is significant, should be uniform 2 1) The <head> information in this page is significant, should be uniform
3 across api docs and should be edited only with knowledge of the 3 across api docs and should be edited only with knowledge of the
4 templating mechanism. 4 templating mechanism.
5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a 5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a
6 browser, it will be re-generated from the template, json schema and 6 browser, it will be re-generated from the template, json schema and
7 authored overview content. 7 authored overview content.
8 4) The <body>.innerHTML is also generated by an offline step so that this 8 4) The <body>.innerHTML is also generated by an offline step so that this
9 page may easily be indexed by search engines. 9 page may easily be indexed by search engines.
10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> 10 --><html xmlns="http://www.w3.org/1999/xhtml"><head>
11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
12 <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css"> 12 <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css">
13 <link href="css/print.css" rel="stylesheet" type="text/css" media="print"> 13 <link href="css/print.css" rel="stylesheet" type="text/css" media="print">
14 <script type="text/javascript" src="../../../third_party/jstemplate/jstempla te_compiled.js"> 14 <script type="text/javascript" src="../../../third_party/jstemplate/jstempla te_compiled.js">
15 </script> 15 </script>
16 <script type="text/javascript" src="js/api_page_generator.js"></script> 16 <script type="text/javascript" src="js/api_page_generator.js"></script>
17 <script type="text/javascript" src="js/bootstrap.js"></script> 17 <script type="text/javascript" src="js/bootstrap.js"></script>
18 <script type="text/javascript" src="js/sidebar.js"></script> 18 <script type="text/javascript" src="js/sidebar.js"></script>
19 <title>chrome.experimental.speechInput - Google Chrome Extensions - Google Cod e</title></head> 19 <title>Speech Input API - Google Chrome Extensions - Google Code</title></head >
20 <body> <div id="gc-container" class="labs"> 20 <body> <div id="gc-container" class="labs">
21 <div id="devModeWarning"> 21 <div id="devModeWarning">
22 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. 22 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.
23 </div> 23 </div>
24 <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION --> 24 <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION -->
25 <!-- In particular, sub-templates that recurse, must be used by allowing 25 <!-- In particular, sub-templates that recurse, must be used by allowing
26 jstemplate to make a copy of the template in this section which 26 jstemplate to make a copy of the template in this section which
27 are not operated on by way of the jsskip="true" --> 27 are not operated on by way of the jsskip="true" -->
28 <div style="display:none"> 28 <div style="display:none">
29 29
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 </ul> 284 </ul>
285 </li> 285 </li>
286 </ul> 286 </ul>
287 </div> 287 </div>
288 <script> 288 <script>
289 initToggles(); 289 initToggles();
290 </script> 290 </script>
291 291
292 <div class="g-unit" id="gc-pagecontent"> 292 <div class="g-unit" id="gc-pagecontent">
293 <div id="pageTitle"> 293 <div id="pageTitle">
294 <h1 class="page_title">chrome.experimental.speechInput</h1> 294 <h1 class="page_title">Speech Input API</h1>
295 </div> 295 </div>
296 <!-- TABLE OF CONTENTS --> 296 <!-- TABLE OF CONTENTS -->
297 <div id="toc"> 297 <div id="toc">
298 <h2>Contents</h2> 298 <h2>Contents</h2>
299 <ol> 299 <ol>
300 <li style="display: none; "> 300 <li>
301 <a>h2Name</a> 301 <a href="#manifest">Manifest</a>
302 <ol> 302 <ol>
303 <li> 303 <li style="display: none; ">
304 <a>h3Name</a> 304 <a>h3Name</a>
305 </li> 305 </li>
306 </ol> 306 </ol>
307 </li><li>
308 <a href="#howToStart">How to start speech recognition</a>
309 <ol>
310 <li style="display: none; ">
311 <a>h3Name</a>
312 </li>
313 </ol>
314 </li><li>
315 <a href="#howToGetResults">How to get speech recognition results</ a>
316 <ol>
317 <li style="display: none; ">
318 <a>h3Name</a>
319 </li>
320 </ol>
321 </li><li>
322 <a href="#howToStop">How to stop recording</a>
323 <ol>
324 <li style="display: none; ">
325 <a>h3Name</a>
326 </li>
327 </ol>
328 </li><li>
329 <a href="#otherFeatures">Other features</a>
330 <ol>
331 <li style="display: none; ">
332 <a>h3Name</a>
333 </li>
334 </ol>
335 </li><li>
336 <a href="#examples">Examples</a>
337 <ol>
338 <li style="display: none; ">
339 <a>h3Name</a>
340 </li>
341 </ol>
307 </li> 342 </li>
308 <li> 343 <li>
309 <a href="#apiReference">API reference: chrome.experimental.speec hInput</a> 344 <a href="#apiReference">API reference: chrome.experimental.speec hInput</a>
310 <ol> 345 <ol>
311 <li style="display: none; "> 346 <li style="display: none; ">
312 <a href="#properties">Properties</a> 347 <a href="#properties">Properties</a>
313 <ol> 348 <ol>
314 <li> 349 <li>
315 <a href="#property-anchor">propertyName</a> 350 <a href="#property-anchor">propertyName</a>
316 </li> 351 </li>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 </li> 463 </li>
429 </ol> 464 </ol>
430 </li> 465 </li>
431 </ol> 466 </ol>
432 </li> 467 </li>
433 </ol> 468 </ol>
434 </div> 469 </div>
435 <!-- /TABLE OF CONTENTS --> 470 <!-- /TABLE OF CONTENTS -->
436 471
437 <!-- Standard content lead-in for experimental API pages --> 472 <!-- Standard content lead-in for experimental API pages -->
438 <p id="classSummary"> 473 <p id="classSummary" style="display: none; ">
439 For information on how to use experimental APIs, see the <a href="expe rimental.html">chrome.experimental.* APIs</a> page. 474 For information on how to use experimental APIs, see the <a href="expe rimental.html">chrome.experimental.* APIs</a> page.
440 </p> 475 </p>
441 476
442 <!-- STATIC CONTENT PLACEHOLDER --> 477 <!-- STATIC CONTENT PLACEHOLDER -->
443 <div id="static"></div> 478 <div id="static"><div id="pageData-name" class="pageData">Speech Input A PI</div>
479
480 <!-- BEGIN AUTHORED CONTENT -->
481 <p id="classSummary">
482 The <code>chrome.experimental.speechInput</code> module provides
483 one-shot speech recognition to Chrome extensions.
484 This module is still experimental. For information on how to use experimental
485 APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
486 </p>
487
488 <h2 id="manifest">Manifest</h2>
489 <p>You must declare the "experimental" permission in the <a href="manifest.html" >extension manifest</a> to use the speech input
490 API.
491 For example:</p>
492 <pre>{
493 "name": "My extension",
494 ...
495 <b>"permissions": [
496 "experimental"
497 ]</b>,
498 ...
499 }</pre>
500
501 <h2 id="howToStart">How to start speech recognition</h2>
502 <p>To start recognizing speech an extension must call the <code>start()</code>
503 method. If provided, your callback will be called once recording has
504 successfully started. In case of error <code>chrome.extension.lastError</code>
505 will be set.</p>
506
507 <p>This API provides exclusive access to the default recording device to the
508 first extension requesting it. Consequently, any calls to <code>start()</code>
509 when the device is being used by another extension or web page will fail and set
510 <code>chrome.extension.lastError</code>. The message <code>requestDenied</code>
511 will be set if another extension in the same profile is making use of the API.
512 Otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code>
513 or <code>unableToStart</code> will be set depending on the situation.</p>
514
515 <p>To check whether recording is currently active, call the
516 <code>isRecording()</code> method. Please note that it only checks for audio
517 recording within Chrome.</p>
518
519
520 <h2 id="howToGetResults">How to get speech recognition results</h2>
521 <p>Listen to the <code>onResult</code> event to receive speech recognition
522 results.</p>
523
524 <pre>var callback = function(result) { ... };
525
526 chrome.experimental.speechInput.onResult.addListener(callback);
527 </pre>
528
529 <p>The <code>result</code> object contains an array of
530 <a href="#type-SpeechInputResultHypothesis">SpeechInputResultHypothesis</a>
531 sorted by decreasing likelihood.</p>
532
533 <p>Recording automatically stops when results are received. It is safe to call
534 <code>start()</code> again from the results callback.</p>
535
536 <p>To handle errors during speech recognition listen for the
537 <code>onError</code> event.</p>
538
539 <pre>var callback = function(error) { ... };
540
541 chrome.experimental.speechInput.onError.addListener(callback);
542 </pre>
543
544 <p></p>Recording will automatically stop in case of error.
545 It is safe to call <code>start()</code> again from the error callback.<p></p>
546
547
548 <h2 id="howToStop">How to stop recording</h2>
549 <p>To stop speech recognition call the <code>stop()</code> method. If provided,
550 the callback funciton will be called once recording has successfully stopped.
551 In case of error <code>chrome.extension.lastError</code> will be set.
552 </p>
553
554
555 <h2 id="otherFeatures">Other features</h2>
556 <ul><li>
557 <code>onSoundStart</code> - Event generated when start of sound is detected
558 (from previously being silent).
559 </li><li>
560 <code>onSoundEnd</code> - Event generated when end of sound is detected (a
561 continued period of silence).
562 </li></ul>
563
564
565 <h2 id="examples">Examples</h2>
566 <p>The following example illustrates how to show a JavaScript alert with the
567 most likely recognition result.</p>
568 <pre>function checkStart() {
569 if (chrome.extension.lastError) {
570 alert("Couldn't start speech input: " + chrome.extension.lastError.message);
571 }
572 }
573
574 function recognitionFailed(error) {
575 alert("Speech input failed: " + error.code);
576 }
577
578 function recognitionSucceeded(result) {
579 alert("Recognized '" + result.hypotheses[0].utterance + "' with confidence " + result.hypotheses[0].confidence);
580 }
581
582 chrome.experimental.speechInput.onError.addListener(recognitionFailed);
583 chrome.experimental.speechInput.onResult.addListener(recognitionSucceded);
584 chrome.experimental.speechInput.start({ "language": "en" }, checkStart);
585 </pre>
586 </div>
444 587
445 <!-- API PAGE --> 588 <!-- API PAGE -->
446 <div class="apiPage"> 589 <div class="apiPage">
447 <a name="apiReference"></a> 590 <a name="apiReference"></a>
448 <h2>API reference: chrome.experimental.speechInput</h2> 591 <h2>API reference: chrome.experimental.speechInput</h2>
449 592
450 <!-- PROPERTIES --> 593 <!-- PROPERTIES -->
451 <div class="apiGroup" style="display: none; "> 594 <div class="apiGroup" style="display: none; ">
452 <a name="properties"></a> 595 <a name="properties"></a>
453 <h3 id="properties">Properties</h3> 596 <h3 id="properties">Properties</h3>
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 _uff=0; 2267 _uff=0;
2125 urchinTracker(); 2268 urchinTracker();
2126 } 2269 }
2127 catch(e) {/* urchinTracker not available. */} 2270 catch(e) {/* urchinTracker not available. */}
2128 </script> 2271 </script>
2129 <!-- end analytics --> 2272 <!-- end analytics -->
2130 </div> 2273 </div>
2131 </div> <!-- /gc-footer --> 2274 </div> <!-- /gc-footer -->
2132 </div> <!-- /gc-container --> 2275 </div> <!-- /gc-container -->
2133 </body></html> 2276 </body></html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698