Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / test / data / speech / web_speech_recognition.html
blob175ed3b565f353350d1921913adeca2ae095daf0
1 <!doctype html>
2 <meta charset="utf-8">
3 <title> Web Speech Recognition </title>
5 <script>
6 var successes = 0;
7 var hash = window.location.hash;
8 var recognizer = new webkitSpeechRecognition();
10 (function () {
12 switch (hash) {
13 // Just probe if creating a SpeechRecognition object worked.
14 case "#precheck":
15 notify(recognizer == null ? 'fail' : 'success');
16 return;
18 case "#oneshot":
19 recognizer.continuous = false;
20 break;
22 case "#continuous":
23 recognizer.continuous = true;
24 break;
26 default:
27 return;
30 recognizer.onresult = function(e) {
31 var value = e.results[e.resultIndex][0].transcript;
32 if (value == 'Pictures of the moon') {
33 successes++;
34 notify('goodresult' + successes);
35 } else {
36 notify('badresult');
39 recognizer.onerror = function(e) {
40 console.log('error', e);
41 notify('error' + e.error);
43 recognizer.onnomatch = function() { console.log('nomatch'); }
44 recognizer.onaudiostart = function() { console.log('audiostart'); }
45 recognizer.onsoundstart = function() { console.log('soundstart'); }
46 recognizer.onsoundend = function() { console.log('soundend'); }
47 recognizer.onaudioend = function() { console.log('audioend'); }
49 recognizer.start();
51 })();
53 function notify(status) {
54 document.location = '#' + status;
55 document.location.reload(true);
57 </script>