OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <script> |
| 3 function setStartIcon() { |
| 4 chrome.browserAction.setIcon({ path: "start.png" }); |
| 5 } |
| 6 |
| 7 function setStopIcon() { |
| 8 chrome.browserAction.setIcon({ path: "stop.png" }); |
| 9 } |
| 10 |
| 11 chrome.browserAction.onClicked.addListener(function(tab) { |
| 12 chrome.experimental.speechInput.isRecording(function(recording) { |
| 13 if (!recording) { |
| 14 chrome.experimental.speechInput.start({}, function() { |
| 15 if (chrome.extension.lastError) { |
| 16 alert("Couldn't start speech input: " + chrome.extension.lastError.mes
sage); |
| 17 setStartIcon(); |
| 18 } else { |
| 19 setStopIcon(); |
| 20 } |
| 21 }); |
| 22 } else { |
| 23 chrome.experimental.speechInput.stop(function() { |
| 24 setStartIcon(); |
| 25 }); |
| 26 } |
| 27 }); |
| 28 }); |
| 29 |
| 30 chrome.experimental.speechInput.onError.addListener(function(error) { |
| 31 alert("Speech input failed: " + error.code); |
| 32 setStartIcon(); |
| 33 }); |
| 34 |
| 35 chrome.experimental.speechInput.onResult.addListener(function(result) { |
| 36 alert(result.hypotheses[0].utterance); |
| 37 setStartIcon(); |
| 38 }); |
| 39 </script> |
| 40 </html> |
OLD | NEW |