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

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: 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 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. It provides exclusive
484 access to the default recording device to the first extension requesting it.
485 This module is still experimental. For information on how to use experimental
486 APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
487 </p>
488
489 <h2 id="manifest">Manifest</h2>
490 <p>You must declare the "experimental" permission in the <a href="manifest.html" >extension manifest</a> to use the speechInput
491 API.
492 For example:</p>
493 <pre>{
494 "name": "My extension",
495 ...
496 <b>"permissions": [
497 "experimental"
498 ]</b>,
499 ...
500 }</pre>
501
502 <h2 id="howToStart">How to start speech recognition</h2>
503 <p>To start recognizing speech an extension must call the <code>start</code> met hod.
504 This will asynchronously request to start a new session for speech recognition.
505 If provided, <code>callback</code> will be called once the actual recording has
506 successfully started. A microphone tray icon will appear on the task bar during
507 all the recognition session. In case of error during the start the call will
508 fail and <code>chrome.extension.lastError</code> will be set.</p>
509
510 <p>This API provides exclusive access to the default recording device to the fir st
511 extension requesting it. Consequently, any calls to start when the device is
512 being used by anything else than the current extension will fail and set
513 <code>chrome.extension.lastError</code>. The message <code>requestDenied</code>
514 will be set if another extension in the same profile is making use of the API,
515 otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code>
516 or <code>unableToStart</code> will be set depending on the situation.</p>
517
518 <p>To check if recording is currently in use call the <code>isRecording</code>
519 method. Please note that its result is limited to audio recording within Chrome. </p>
520
521 <p>Repeated calls for the same session from the extension currently accessing th e
522 device will also fail and set the error code to <code>requestInProgress</code>
523 or <code>invalidOperation</code> depending on the state of the first request.</p >
524
525
526 <h2 id="howToGetResults">How to get speech recognition results</h2>
527 <p>To listen for speech recognition results the API provides the function
528 <code>chrome.experimental.speechInput.onResult.addListener()</code> with the
529 following signature.</p>
530
531 <pre>var callback = function(result) { ... };
532
533 chrome.experimental.speechInput.onResult.addListener(callback);
534 </pre>
535
536 <p>The <code>result</code> object contains an array of recognition hypotheses
537 sorted by decreasing likelihood.</p>
538
539 <p>Recording automatically stops when results are received. It is safe to call
540 <code>start</code> again from the results callback.</p>
541
542 <p>If there is an error during the recognition process or nothing could be
543 recognized the <code>onError</code> event will be generated. To listen for
544 recognition-time errors use the
545 <code>chrome.experimental.speechInput.onError.addListener()</code> function
546 in the same way as with <code>onResult</code>. Recording will automatically
547 stop in case on error. It is safe to call <code>start</code> again
548 from the error callback.</p>
549
550
551 <h2 id="howToStop">How to stop recording</h2>
552 <p>If an extension is currently recording for speech input it can request to sto p
553 anytime by calling the <code>stop</code> method. This will asynchronously
554 request to finish the current speech recognition session ignoring any results.
555 If provided, <code>callback</code> will be called once recording has
556 successfully stopped.</p>
557
558 <p>Any errors during the stop process will set
559 <code>chrome.extension.lastError</code>. Repeated calls for the same session
560 from the extension currently accessing the device will also fail and set the
561 error code to <code>requestInProgress</code> or <code>invalidOperation</code>
562 depending on the state of the first request.</p>
563
564
565 <h2 id="otherFeatures">Other features</h2>
566 <p>This API also generates events when sound is detected to start and stop
567 during a recording session. To listen to them use the functions
568 <code>chrome.experimental.speechInput.onSoundStart()</code> and
569 <code>chrome.experimental.speechInput.onSoundEnd()</code>.</p>
570
571
572 <h2 id="examples">Examples</h2>
573 <p>The following example illustrates how to show a javascript alert with the
574 most likely recognition result.</p>
575 <pre>function checkStart() {
576 if (chrome.extension.lastError) {
577 alert("Couldn't start speech input: " + chrome.extension.lastError.message);
578 }
579 }
580
581 function recognitionFailed(error) {
582 alert("Speech input failed: " + error.code);
583 }
584
585 function recognitionSucceeded(result) {
586 alert(result.hypotheses[0].utterance);
587 }
588
589 chrome.experimental.speechInput.onError.addListener(recognitionFailed);
590 chrome.experimental.speechInput.onResult.addListener(recognitionSucceded);
591 chrome.experimental.speechInput.start({ "language": "en" }, checkStart);
592 </pre>
593 </div>
444 594
445 <!-- API PAGE --> 595 <!-- API PAGE -->
446 <div class="apiPage"> 596 <div class="apiPage">
447 <a name="apiReference"></a> 597 <a name="apiReference"></a>
448 <h2>API reference: chrome.experimental.speechInput</h2> 598 <h2>API reference: chrome.experimental.speechInput</h2>
449 599
450 <!-- PROPERTIES --> 600 <!-- PROPERTIES -->
451 <div class="apiGroup" style="display: none; "> 601 <div class="apiGroup" style="display: none; ">
452 <a name="properties"></a> 602 <a name="properties"></a>
453 <h3 id="properties">Properties</h3> 603 <h3 id="properties">Properties</h3>
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 _uff=0; 2274 _uff=0;
2125 urchinTracker(); 2275 urchinTracker();
2126 } 2276 }
2127 catch(e) {/* urchinTracker not available. */} 2277 catch(e) {/* urchinTracker not available. */}
2128 </script> 2278 </script>
2129 <!-- end analytics --> 2279 <!-- end analytics -->
2130 </div> 2280 </div>
2131 </div> <!-- /gc-footer --> 2281 </div> <!-- /gc-footer -->
2132 </div> <!-- /gc-container --> 2282 </div> <!-- /gc-container -->
2133 </body></html> 2283 </body></html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698