| OLD | NEW |
| 1 <p id="classSummary"> | 1 <p id="classSummary"> |
| 2 The <code>chrome.experimental.speechInput</code> module provides | 2 The <code>chrome.experimental.speechInput</code> module provides |
| 3 one-shot speech recognition to Chrome extensions. | 3 one-shot speech recognition to Chrome extensions. |
| 4 This module is still experimental. For information on how to use experimental | 4 This module is still experimental. For information on how to use experimental |
| 5 APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. | 5 APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. |
| 6 </p> | 6 </p> |
| 7 | 7 |
| 8 <h2 id="manifest">Manifest</h2> | 8 <h2 id="manifest">Manifest</h2> |
| 9 <p>You must declare the "experimental" permission in the <a | 9 <p>You must declare the "experimental" permission in the <a |
| 10 href="manifest.html">extension manifest</a> to use the speech input | 10 href="manifest.html">extension manifest</a> to use the speech input |
| 11 API. | 11 API. |
| 12 For example:</p> | 12 For example:</p> |
| 13 <pre>{ | 13 <pre>{ |
| 14 "name": "My extension", | 14 "name": "My extension", |
| 15 ... | 15 ... |
| 16 <b>"permissions": [ | 16 <b>"permissions": [ |
| 17 "experimental" | 17 "experimental" |
| 18 ]</b>, | 18 ]</b>, |
| 19 ... | 19 ... |
| 20 }</pre> | 20 }</pre> |
| 21 | 21 |
| 22 <h2 id="howToStart">How to start speech recognition</h2> | 22 <h2 id="howToStart">How to start speech recognition</h2> |
| 23 <p>To start recognizing speech an extension must call the <code>start()</code> | 23 <p>To start recognizing speech an extension must call the <code>start()</code> |
| 24 method. If provided, your callback will be called once recording has | 24 method. If provided, your callback will be called once recording has |
| 25 successfully started. In case of error <code>chrome.extension.lastError</code> | 25 successfully started. In case of error <code>chrome.runtime.lastError</code> |
| 26 will be set.</p> | 26 will be set.</p> |
| 27 | 27 |
| 28 <p>This API provides exclusive access to the default recording device to the | 28 <p>This API provides exclusive access to the default recording device to the |
| 29 first extension requesting it. Consequently, any calls to <code>start()</code> | 29 first extension requesting it. Consequently, any calls to <code>start()</code> |
| 30 when the device is being used by another extension or web page will fail and set | 30 when the device is being used by another extension or web page will fail and set |
| 31 <code>chrome.extension.lastError</code>. The message <code>requestDenied</code> | 31 <code>chrome.runtime.lastError</code>. The message <code>requestDenied</code> |
| 32 will be set if another extension in the same profile is making use of the API. | 32 will be set if another extension in the same profile is making use of the API. |
| 33 Otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code> | 33 Otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code> |
| 34 or <code>unableToStart</code> will be set depending on the situation.</p> | 34 or <code>unableToStart</code> will be set depending on the situation.</p> |
| 35 | 35 |
| 36 <p>To check whether recording is currently active, call the | 36 <p>To check whether recording is currently active, call the |
| 37 <code>isRecording()</code> method. Please note that it only checks for audio | 37 <code>isRecording()</code> method. Please note that it only checks for audio |
| 38 recording within Chrome.</p> | 38 recording within Chrome.</p> |
| 39 | 39 |
| 40 | 40 |
| 41 <h2 id="howToGetResults">How to get speech recognition results</h2> | 41 <h2 id="howToGetResults">How to get speech recognition results</h2> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 64 chrome.experimental.speechInput.onError.addListener(callback); | 64 chrome.experimental.speechInput.onError.addListener(callback); |
| 65 </pre> | 65 </pre> |
| 66 | 66 |
| 67 </p>Recording will automatically stop in case of error. | 67 </p>Recording will automatically stop in case of error. |
| 68 It is safe to call <code>start()</code> again from the error callback.</p> | 68 It is safe to call <code>start()</code> again from the error callback.</p> |
| 69 | 69 |
| 70 | 70 |
| 71 <h2 id="howToStop">How to stop recording</h2> | 71 <h2 id="howToStop">How to stop recording</h2> |
| 72 <p>To stop speech recognition call the <code>stop()</code> method. If provided, | 72 <p>To stop speech recognition call the <code>stop()</code> method. If provided, |
| 73 the callback function will be called once recording has successfully stopped. | 73 the callback function will be called once recording has successfully stopped. |
| 74 In case of error <code>chrome.extension.lastError</code> will be set. | 74 In case of error <code>chrome.runtime.lastError</code> will be set. |
| 75 </p> | 75 </p> |
| 76 | 76 |
| 77 | 77 |
| 78 <h2 id="otherFeatures">Other features</h2> | 78 <h2 id="otherFeatures">Other features</h2> |
| 79 <ul><li> | 79 <ul><li> |
| 80 <code>onSoundStart</code> - Event generated when start of sound is detected | 80 <code>onSoundStart</code> - Event generated when start of sound is detected |
| 81 (from previously being silent). | 81 (from previously being silent). |
| 82 </li><li> | 82 </li><li> |
| 83 <code>onSoundEnd</code> - Event generated when end of sound is detected (a | 83 <code>onSoundEnd</code> - Event generated when end of sound is detected (a |
| 84 continued period of silence). | 84 continued period of silence). |
| 85 </li></ul> | 85 </li></ul> |
| 86 | 86 |
| 87 | 87 |
| 88 <h2 id="examples">Examples</h2> | 88 <h2 id="examples">Examples</h2> |
| 89 <p>The following example illustrates how to show a JavaScript alert with the | 89 <p>The following example illustrates how to show a JavaScript alert with the |
| 90 most likely recognition result.</p> | 90 most likely recognition result.</p> |
| 91 <pre> | 91 <pre> |
| 92 function checkStart() { | 92 function checkStart() { |
| 93 if (chrome.extension.lastError) { | 93 if (chrome.runtime.lastError) { |
| 94 alert("Couldn't start speech input: " + chrome.extension.lastError.message); | 94 alert("Couldn't start speech input: " + chrome.runtime.lastError.message); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 function recognitionFailed(error) { | 98 function recognitionFailed(error) { |
| 99 alert("Speech input failed: " + error.code); | 99 alert("Speech input failed: " + error.code); |
| 100 } | 100 } |
| 101 | 101 |
| 102 function recognitionSucceeded(result) { | 102 function recognitionSucceeded(result) { |
| 103 alert("Recognized '" + result.hypotheses[0].utterance + "' with confidence " +
result.hypotheses[0].confidence); | 103 alert("Recognized '" + result.hypotheses[0].utterance + "' with confidence " +
result.hypotheses[0].confidence); |
| 104 } | 104 } |
| 105 | 105 |
| 106 chrome.experimental.speechInput.onError.addListener(recognitionFailed); | 106 chrome.experimental.speechInput.onError.addListener(recognitionFailed); |
| 107 chrome.experimental.speechInput.onResult.addListener(recognitionSucceeded); | 107 chrome.experimental.speechInput.onResult.addListener(recognitionSucceeded); |
| 108 chrome.experimental.speechInput.start({ "language": "en" }, checkStart); | 108 chrome.experimental.speechInput.start({ "language": "en" }, checkStart); |
| 109 </pre> | 109 </pre> |
| OLD | NEW |