OLD | NEW |
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 </ul> | 287 </ul> |
288 </li> | 288 </li> |
289 </ul> | 289 </ul> |
290 </div> | 290 </div> |
291 <script> | 291 <script> |
292 initToggles(); | 292 initToggles(); |
293 </script> | 293 </script> |
294 | 294 |
295 <div class="g-unit" id="gc-pagecontent"> | 295 <div class="g-unit" id="gc-pagecontent"> |
296 <div id="pageTitle"> | 296 <div id="pageTitle"> |
297 <h1 class="page_title">chrome.experimental.speechInput</h1> | 297 <h1 class="page_title">Speech Input API</h1> |
298 </div> | 298 </div> |
299 <!-- TABLE OF CONTENTS --> | 299 <!-- TABLE OF CONTENTS --> |
300 <div id="toc"> | 300 <div id="toc"> |
301 <h2>Contents</h2> | 301 <h2>Contents</h2> |
302 <ol> | 302 <ol> |
303 <li style="display: none; "> | 303 <li> |
304 <a>h2Name</a> | 304 <a href="#manifest">Manifest</a> |
305 <ol> | 305 <ol> |
306 <li> | 306 <li style="display: none; "> |
307 <a>h3Name</a> | 307 <a>h3Name</a> |
308 </li> | 308 </li> |
309 </ol> | 309 </ol> |
| 310 </li><li> |
| 311 <a href="#howToStart">How to start speech recognition</a> |
| 312 <ol> |
| 313 <li style="display: none; "> |
| 314 <a>h3Name</a> |
| 315 </li> |
| 316 </ol> |
| 317 </li><li> |
| 318 <a href="#howToGetResults">How to get speech recognition results</
a> |
| 319 <ol> |
| 320 <li style="display: none; "> |
| 321 <a>h3Name</a> |
| 322 </li> |
| 323 </ol> |
| 324 </li><li> |
| 325 <a href="#howToStop">How to stop recording</a> |
| 326 <ol> |
| 327 <li style="display: none; "> |
| 328 <a>h3Name</a> |
| 329 </li> |
| 330 </ol> |
| 331 </li><li> |
| 332 <a href="#otherFeatures">Other features</a> |
| 333 <ol> |
| 334 <li style="display: none; "> |
| 335 <a>h3Name</a> |
| 336 </li> |
| 337 </ol> |
| 338 </li><li> |
| 339 <a href="#examples">Examples</a> |
| 340 <ol> |
| 341 <li style="display: none; "> |
| 342 <a>h3Name</a> |
| 343 </li> |
| 344 </ol> |
310 </li> | 345 </li> |
311 <li> | 346 <li> |
312 <a href="#apiReference">API reference: chrome.experimental.speec
hInput</a> | 347 <a href="#apiReference">API reference: chrome.experimental.speec
hInput</a> |
313 <ol> | 348 <ol> |
314 <li style="display: none; "> | 349 <li style="display: none; "> |
315 <a href="#properties">Properties</a> | 350 <a href="#properties">Properties</a> |
316 <ol> | 351 <ol> |
317 <li> | 352 <li> |
318 <a href="#property-anchor">propertyName</a> | 353 <a href="#property-anchor">propertyName</a> |
319 </li> | 354 </li> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 </li> | 466 </li> |
432 </ol> | 467 </ol> |
433 </li> | 468 </li> |
434 </ol> | 469 </ol> |
435 </li> | 470 </li> |
436 </ol> | 471 </ol> |
437 </div> | 472 </div> |
438 <!-- /TABLE OF CONTENTS --> | 473 <!-- /TABLE OF CONTENTS --> |
439 | 474 |
440 <!-- Standard content lead-in for experimental API pages --> | 475 <!-- Standard content lead-in for experimental API pages --> |
441 <p id="classSummary"> | 476 <p id="classSummary" style="display: none; "> |
442 For information on how to use experimental APIs, see the <a href="expe
rimental.html">chrome.experimental.* APIs</a> page. | 477 For information on how to use experimental APIs, see the <a href="expe
rimental.html">chrome.experimental.* APIs</a> page. |
443 </p> | 478 </p> |
444 | 479 |
445 <!-- STATIC CONTENT PLACEHOLDER --> | 480 <!-- STATIC CONTENT PLACEHOLDER --> |
446 <div id="static"></div> | 481 <div id="static"><div id="pageData-name" class="pageData">Speech Input A
PI</div> |
| 482 |
| 483 <!-- BEGIN AUTHORED CONTENT --> |
| 484 <p id="classSummary"> |
| 485 The <code>chrome.experimental.speechInput</code> module provides |
| 486 one-shot speech recognition to Chrome extensions. |
| 487 This module is still experimental. For information on how to use experimental |
| 488 APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. |
| 489 </p> |
| 490 |
| 491 <h2 id="manifest">Manifest</h2> |
| 492 <p>You must declare the "experimental" permission in the <a href="manifest.html"
>extension manifest</a> to use the speech input |
| 493 API. |
| 494 For example:</p> |
| 495 <pre>{ |
| 496 "name": "My extension", |
| 497 ... |
| 498 <b>"permissions": [ |
| 499 "experimental" |
| 500 ]</b>, |
| 501 ... |
| 502 }</pre> |
| 503 |
| 504 <h2 id="howToStart">How to start speech recognition</h2> |
| 505 <p>To start recognizing speech an extension must call the <code>start()</code> |
| 506 method. If provided, your callback will be called once recording has |
| 507 successfully started. In case of error <code>chrome.extension.lastError</code> |
| 508 will be set.</p> |
| 509 |
| 510 <p>This API provides exclusive access to the default recording device to the |
| 511 first extension requesting it. Consequently, any calls to <code>start()</code> |
| 512 when the device is being used by another extension or web page 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 whether recording is currently active, call the |
| 519 <code>isRecording()</code> method. Please note that it only checks for audio |
| 520 recording within Chrome.</p> |
| 521 |
| 522 |
| 523 <h2 id="howToGetResults">How to get speech recognition results</h2> |
| 524 <p>Listen to the <code>onResult</code> event to receive speech recognition |
| 525 results.</p> |
| 526 |
| 527 <pre>var callback = function(result) { ... }; |
| 528 |
| 529 chrome.experimental.speechInput.onResult.addListener(callback); |
| 530 </pre> |
| 531 |
| 532 <p>The <code>result</code> object contains an array of |
| 533 <a href="#type-SpeechInputResultHypothesis">SpeechInputResultHypothesis</a> |
| 534 sorted by decreasing likelihood.</p> |
| 535 |
| 536 <p>Recording automatically stops when results are received. It is safe to call |
| 537 <code>start()</code> again from the results callback.</p> |
| 538 |
| 539 <p>To handle errors during speech recognition listen for the |
| 540 <code>onError</code> event.</p> |
| 541 |
| 542 <pre>var callback = function(error) { ... }; |
| 543 |
| 544 chrome.experimental.speechInput.onError.addListener(callback); |
| 545 </pre> |
| 546 |
| 547 <p></p>Recording will automatically stop in case of error. |
| 548 It is safe to call <code>start()</code> again from the error callback.<p></p> |
| 549 |
| 550 |
| 551 <h2 id="howToStop">How to stop recording</h2> |
| 552 <p>To stop speech recognition call the <code>stop()</code> method. If provided, |
| 553 the callback function will be called once recording has successfully stopped. |
| 554 In case of error <code>chrome.extension.lastError</code> will be set. |
| 555 </p> |
| 556 |
| 557 |
| 558 <h2 id="otherFeatures">Other features</h2> |
| 559 <ul><li> |
| 560 <code>onSoundStart</code> - Event generated when start of sound is detected |
| 561 (from previously being silent). |
| 562 </li><li> |
| 563 <code>onSoundEnd</code> - Event generated when end of sound is detected (a |
| 564 continued period of silence). |
| 565 </li></ul> |
| 566 |
| 567 |
| 568 <h2 id="examples">Examples</h2> |
| 569 <p>The following example illustrates how to show a JavaScript alert with the |
| 570 most likely recognition result.</p> |
| 571 <pre>function checkStart() { |
| 572 if (chrome.extension.lastError) { |
| 573 alert("Couldn't start speech input: " + chrome.extension.lastError.message); |
| 574 } |
| 575 } |
| 576 |
| 577 function recognitionFailed(error) { |
| 578 alert("Speech input failed: " + error.code); |
| 579 } |
| 580 |
| 581 function recognitionSucceeded(result) { |
| 582 alert("Recognized '" + result.hypotheses[0].utterance + "' with confidence " +
result.hypotheses[0].confidence); |
| 583 } |
| 584 |
| 585 chrome.experimental.speechInput.onError.addListener(recognitionFailed); |
| 586 chrome.experimental.speechInput.onResult.addListener(recognitionSucceded); |
| 587 chrome.experimental.speechInput.start({ "language": "en" }, checkStart); |
| 588 </pre> |
| 589 </div> |
447 | 590 |
448 <!-- API PAGE --> | 591 <!-- API PAGE --> |
449 <div class="apiPage"> | 592 <div class="apiPage"> |
450 <a name="apiReference"></a> | 593 <a name="apiReference"></a> |
451 <h2>API reference: chrome.experimental.speechInput</h2> | 594 <h2>API reference: chrome.experimental.speechInput</h2> |
452 | 595 |
453 <!-- PROPERTIES --> | 596 <!-- PROPERTIES --> |
454 <div class="apiGroup" style="display: none; "> | 597 <div class="apiGroup" style="display: none; "> |
455 <a name="properties"></a> | 598 <a name="properties"></a> |
456 <h3 id="properties">Properties</h3> | 599 <h3 id="properties">Properties</h3> |
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2127 _uff=0; | 2270 _uff=0; |
2128 urchinTracker(); | 2271 urchinTracker(); |
2129 } | 2272 } |
2130 catch(e) {/* urchinTracker not available. */} | 2273 catch(e) {/* urchinTracker not available. */} |
2131 </script> | 2274 </script> |
2132 <!-- end analytics --> | 2275 <!-- end analytics --> |
2133 </div> | 2276 </div> |
2134 </div> <!-- /gc-footer --> | 2277 </div> <!-- /gc-footer --> |
2135 </div> <!-- /gc-container --> | 2278 </div> <!-- /gc-container --> |
2136 </body></html> | 2279 </body></html> |
OLD | NEW |