This repository has been archived by the owner on Jul 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeak and listen then puzzle 2.xml
134 lines (134 loc) · 20.8 KB
/
speak and listen then puzzle 2.xml
1
<project name="speak and listen then puzzle 2" app="Snap! 4.0, http://snap.berkeley.edu" version="1"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAGxklEQVR4Xu3Yf0zUdRzH8deBAienSDnWGrdmCp7NaY0NAVdJ+le/ABvgXD+k1eSPNgZ/lGYyJwjVcNTastYfapsbNNfGlGXYBComksSi4S/YkbYpNILa7odwx1277y0mqSlv3vlJ9rp/3MG935+7xz3vjtMWDofD4IUChgRsDNCQPI+1BBggQzAqcNMAe3p60NbWZvSOzaXDs7OzkZWVNZcektpjuSHAxsZGZGRkqB0w00UDX+zFH2eOwjbTwf/h7ZetehSLX/7EumcjIyOM8CbP0bQAOzs7sWjRIkS+l9hsNiP/Bj7YgOX3xc0gp0iq//X3qL/P+MdZNhtwm+9wl185PuV44sQJlJWVzeCxzf2bTgtw165d2LRpkxVf5GPY5XJh69atOHDgAAoLC5GTk4OSkhLreuQjpaamBnV1ddbty8vL0dzcbF2vrKyE1+tFUVERqqurUVFRgZaWFuTn51vXu7u7sWXLFmumtLTU+v3JkyetPQs/exrLProM/8FXEfPACoSGLsBecgjeuvUIjwxifvZLmPz1p+gfsAtTEJf1ImJX5GLim3rEPfUGwp5RBC+2IvjzV0go2gf/p5uxoPxreHY8jMQ3v0Ww/zsEOg5aPwt0H8GkuxPBH79E4vYOa2fo90uIfXAVgoNdmJf+OMITPtgS74fnrYfgeO8SQpfOAPYk+PZtgKPWjbD/T4S9Y5js/x7zH8uPzrnWw3/oNUxeaEP/5qapF3NXVxe2bds296uawSOcFmB9fT3WrVtnvWJ7e3vhdruRlJSEvLw89Pf3W2vXrl2L9vZ2JCQkYOnSpbhy5Qr8fj+cTqd1G7vdjtzcXJw/fx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5FbhAIMUAjHMR0BBqjjyC1CAQYohOOYjgAD1HHkFqEAAxTCcUxHgAHqOHKLUIABCuE4piPAAHUcuUUowACFcBzTEWCAOo7cIhRggEI4jukIMEAdR24RCjBAIRzHdAQYoI4jtwgFGKAQjmM6AgxQx5FbhAIMUAjHMR0BBqjjyC1CAQYohOOYjgAD1HHkFqEAAxTCcUxHgAHqOHKLUIABCuE4piPAAHUcuUUowACFcBzTEWCAOo7cIhRggEI4jukIMEAdR24RCjBAIRzHdAQYoI4jtwgFGKAQjmM6AgxQx5FbhAIMUAjHMR0BBqjjyC1CAQYohOOYjgAD1HHkFqEAAxTCcUxHgAHqOHKLUIABCuE4piPAAHUcuUUowACFcBzTEWCAOo7cIhT4C6Kmr8Z8+ZEWAAAAAElFTkSuQmCC</thumbnail><stage name="Stage" width="480" height="360" costume="0" tempo="60" threadsafe="false" lines="round" codify="false" inheritance="false" sublistIDs="false" scheduled="false" id="1"><pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAOhUlEQVR4Xu3VwQkAAAjEMN1/abewn7jAQRC64wgQIECAAIF3gX1fNEiAAAECBAiMAHsCAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQ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QIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQIHLFxAWmhEwHPAAAAAElFTkSuQmCC</pentrails><costumes><list id="2"></list></costumes><sounds><list id="3"></list></sounds><variables></variables><blocks></blocks><scripts></scripts><sprites><sprite name="Sprite" idx="1" x="0" y="0" heading="90" scale="1" rotation="1" draggable="true" costume="0" color="80,80,80" pen="tip" id="8"><costumes><list id="9"></list></costumes><sounds><list id="10"></list></sounds><variables></variables><blocks></blocks><scripts><script x="21" y="18"><block s="receiveGo"></block><custom-block s="speak %s then %cmdRing in language %s with pitch %n with rate %n with voice %n with volume %n"><l>Say something</l><block s="reifyScript"><script><custom-block s="listen"></custom-block></script><list></list></block><l></l><l></l><l></l><l></l><l></l></custom-block></script><script x="23" y="110"><block s="receiveMessage"><l>heard something</l></block></script><script x="21" y="163"><block s="reportEquals"><l></l><l></l></block></script><script x="93" y="164"><block var="last thing spoken"/></script><script x="23" y="194"><block s="doIf"><l/><script></script></block></script><script x="91" y="200"><block s="turn"><l>15</l></block></script><script x="270" y="130"><custom-block s="save project %txt"><l>speak and listen</l></custom-block></script><script x="270" y="180"><custom-block s="open project %txt"><l>speak and listen</l></custom-block></script></scripts></sprite><watcher var="last thing spoken" style="normal" x="10" y="10" color="243,118,29"/><watcher var="listening" style="normal" x="10" y="31.000001999999995" color="243,118,29" hidden="true"/></sprites></stage><hidden></hidden><headers></headers><code></code><blocks><block-definition s="speak %'text' %'what to do when finished'" type="command" category="sound"><header></header><code></code><inputs><input type="%s"></input><input type="%cmdRing"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>message</l><l>finished_callback</l></list><l>var utterance = new SpeechSynthesisUtterance(message);






if (typeof finished_callback === 'object') {






 // callback provided






 utterance.onend = function (event) {






 invoke(finished_callback, new List([message]));






 };






}






if (window.speech_recognition) {






 window.speech_recognition.abort();






}






window.speechSynthesis.speak(utterance);






</l></block><list><block var="text"/><block var="what to do when finished"/></list></block></script></block-definition><block-definition s="listen and then %'do with recognised words' %'do if nothing recognised'" type="command" category="other"><header></header><code></code><inputs><input type="%cmdRing"></input><input type="%cmdRing"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>spoken_callback</l><l>error_callback</l></list><l>var restart = function () {






 if (window.speechSynthesis.speaking) { // don't listen while speaking






 // there remains the possibility of speech happening after recognition starts






 setTimeout(restart, 500); // try again in half a second






 return;






 }






 try {






 window.speech_recognition.start();






 console.log("recognition started");






 } catch (error) {






 if (error.name === 'InvalidStateError') {






 // delay needed at least in Chrome 52






 setTimeout(restart, 2000);






 } else {






 console.log(error);






 }






 }






};






var handle_result = function (callback, event) {






 var spoken = event.results[0][0].transcript;






 console.log("Confidence is " + event.results[0][0].confidence + " for " + spoken, spoken_callback);






 window.speech_recognition.stop();






 invoke(callback, new List([spoken]));






};






var handle_error = function (callback, event) {






 if (event.error === 'aborted') {






 console.log("aborted so restarting speech recognition in half a second");






 setTimeout(restart, 500);






 return;






 }






 if (event.error === 'no-speech') {






 window.speech_recognition.onend = null;






 window.speech_recognition.onresult = null;






 window.speech_recognition.stop();






 }






 console.log("Recognition error: " + event.error);






 if (typeof callback === 'object') {






 invoke(callback, new List([event.error]));






 }






};






if (!window.speech_recognition) {






 window.speech_recognition = (typeof SpeechRecognition === 'undefined') ? 






 new webkitSpeechRecognition() :






 new SpeechRecognition();






}






window.speech_recognition.onresult = function (event) {






 handle_result(spoken_callback, event);






};






window.speech_recognition.onerror = function (event) {






 handle_error(error_callback, event);






};






window.speech_recognition.onend = function (event) {






 console.log("recognition ended");






 restart(); 






};






restart();






</l></block><list><block var="do with recognised words"/><block var="do if nothing recognised"/></list></block></script></block-definition><block-definition s="listen" type="command" category="other"><header></header><code></code><inputs></inputs><script><custom-block s="Turn off unloading warnings"></custom-block><block s="doSetVar"><l>listening</l><block s="reportBoolean"><l><bool>true</bool></l></block></block><custom-block s="listen and then %cmdRing %cmdRing"><block s="reifyScript"><script><block s="doSetVar"><l>last thing spoken</l><block var="spoken"/></block><block s="doBroadcast"><l>heard something</l></block><custom-block s="listen"></custom-block></script><list><l>spoken</l></list></block><block s="reifyScript"><script><block s="doSetVar"><l>speech recognition error</l><block var="error"/></block><block s="doBroadcast"><l>speech recognition error</l></block><block s="doIf"><block var="listening"/><script><block s="doIfElse"><block s="reportEquals"><block var="speech recognition error"/><l>no-speech</l></block><script><custom-block s="speak %s %cmdRing"><l>I didn't hear anything for a while. Bye.</l><block s="reifyScript"><script></script><list></list></block></custom-block><block s="doSetVar"><l>listening</l><block s="reportBoolean"><l><bool>false</bool></l></block></block></script><script><custom-block s="speak %s %cmdRing"><block s="reportJoinWords"><list><l>There was an error. </l><block var="speech recognition error"/></list></block><block s="reifyScript"><script></script><list></list></block></custom-block><block s="bubble"><block s="reportJoinWords"><list><l>There was an error. </l><block var="speech recognition error"/></list></block></block><custom-block s="speak %s %cmdRing"><l>Try again.</l><block s="reifyScript"><script><custom-block s="listen"></custom-block></script><list></list></block></custom-block></script></block></script></block></script><list><l>error</l></list></block></custom-block></script></block-definition><block-definition s="Turn off unloading warnings" type="command" category="other"><header></header><code></code><inputs></inputs><script><block s="doRun"><block s="reportJSFunction"><list></list><l>window.onbeforeunload = null;</l></block><list></list></block></script></block-definition><block-definition s="speak %'text' then %'what to do when finished' in language %'language code' with pitch %'pitch' with rate %'rate' with voice %'voice' with volume %'volume'" type="command" category="sound"><header></header><code></code><inputs><input type="%s"></input><input type="%cmdRing"></input><input type="%s"></input><input type="%n"></input><input type="%n"></input><input type="%n"></input><input type="%n"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>message</l><l>finished_callback</l><l>lang</l><l>pitch</l><l>rate</l><l>voice</l><l>volume</l></list><l>// see https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance
var utterance = new SpeechSynthesisUtterance(message);
if (lang) {
 utterance.lang = lang;
}
if (pitch > 0) {
 utterance.pitch = pitch;
}
if (rate > 0) {
 if (rate < .1) {
 // A very slow rate breaks Chrome's speech synthesiser
 rate = .1;
 }
 if (rate > 2) {
 rate = 2; // high rate also breaks Chrome's speech synthesis
 }
 utterance.rate = rate;
}
if (voice) {
 voices = window.speechSynthesis.getVoices();
 if (voice >= 0 && voice < voices.length) {
 utterance.voice = voices[Math.floor(voice)];
 } else {
 alert("Only " + voices.length + " voices are available. You can't choose voice number " + voice);
 }
}
if (volume > 0) {
 utterance.volume = volume;
}
if (typeof finished_callback === 'object') {
 // callback provided
 utterance.onend = function (event) {
 invoke(finished_callback, new List([message]));
 };
}
if (window.speech_recognition) {
 window.speech_recognition.abort();
}
window.speechSynthesis.speak(utterance);
</l></block><list><block var="text"/><block var="what to do when finished"/><block var="language code"/><block var="pitch"/><block var="rate"/><block var="voice"/><block var="volume"/></list></block></script></block-definition><block-definition s="save project %'project name'" type="command" category="other"><header></header><code></code><inputs><input type="%txt"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>name</l></list><l>var get_ide = function () {


 var ancestor = this;


 var value;


 while (ancestor && !(ancestor instanceof IDE_Morph)) {


 ancestor = ancestor.parent;


 }


 if (ancestor) {


 return ancestor;


 } else {


 return world.children[0];


 }


}.bind(this);





get_ide().saveProject(name);</l></block><list><block var="project name"/></list></block></script></block-definition><block-definition s="open project %'project name'" type="command" category="other"><header></header><code></code><inputs><input type="%txt"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>name</l></list><l>var get_ide = function () {


 var ancestor = this;


 var value;


 while (ancestor && !(ancestor instanceof IDE_Morph)) {


 ancestor = ancestor.parent;


 }


 if (ancestor) {


 return ancestor;


 } else {


 return world.children[0];


 }


}.bind(this);





get_ide().openProject(name);


</l></block><list><block var="project name"/></list></block></script></block-definition></blocks><variables><variable name="last thing spoken"><l>okay what do you want to hear</l></variable><variable name="listening"><bool>true</bool></variable></variables></project>