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
/
speak and listen then speak.xml
73 lines (73 loc) · 19 KB
/
speak and listen then speak.xml
1
<project name="speak and listen then speak" app="Snap! 4.0, http://snap.berkeley.edu" version="1"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAGxUlEQVR4Xu3YX0jVZxzH8Y+a1RFXwyJ2of2dZbCtMbfMBZts0UUE4p9qOJYZjLoYmNtN0GoQSRciLgYz6MJsbOTYRbGoViyNEbkohMD1z47QhsxNNLb8k6c84/yiQy7bnh6fh3PG3t5E9v1+z+nl23OslGg0GhUfCCRIIIUAEyTPwwYCBEgICRWYMMCOjg61tbUl9In9Fx+8sLBQK1as+C8+9YQ958cCbGlpUX5+fsKeUNfXtbp98VulJOwZPP0DL3rhZT27cX+w2NfXR4RPQTguwPb2ds2YMUOxf5ekpKQk5NfIp2/r+aypT/FXSI7RW5Un416nT59WdXV1cjyxJH8W4wLcuXOnSktLg/hib8N5eXmqrKxUc3OzysrKtHLlSlVVVampqSn4Lq+trVV9fX0wv23bNp04cUJ1dXXatWuXhoaGVF5eHszU1NQo9kUpLi4Ofn/p0iVVVFQEn9+6dWvwa2tra3DnmQNrtOizWxo+uFmpzy3R2K/XFNp8SIN1byra1630wvcUOf+FprxSqvT8cqUtej0gvrN9vtKWFCm0qUmj3+/T1Lc+UPR2j+7d+EFKSw9m0l/doOGmSk0vr9Ng7Wvx+aGG1cqoOaX74fPxe8NNmxR6t1HRkT8VHR1U6uyFilxsmfBO7JM33jka/6a9cOGCtmzZkuRf+uR4euMCbGhoCCKLvQJevnxZ4XBYM2fODMLp6uoKPl9QUKCzZ88qFAppwYIF6unpCWKbO3eurl+/royMDBUVFenq1avq7e3VwMCAli1bFsxlZWVpcHBQhw8f1pw5c7Rnzx4dOXJEOTk5ys3N1ZUrVzT7UIlyij9UWu4but/9o0bbPlf6S2s11v+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jQIBuHLliKUCAlnCsuREgQDeOXLEUIEBLONbcCBCgG0euWAoQoCUca24ECNCNI1csBQjQEo41NwIE6MaRK5YCBGgJx5obAQJ048gVSwECtIRjzY0AAbpx5IqlAAFawrHmRoAA3ThyxVKAAC3hWHMjQIBuHLliKUCAlnCsuREgQDeOXLEUIEBLONbcCBCgG0euWAoQoCUca24ECNCNI1csBQjQEo41NwIE6MaRK5YCBGgJx5obAQJ048gVSwECtIRjzY0AAbpx5IqlAAFawrHmRoAA3ThyxVKAAC3hWHMjQIBuHLliKUCAlnCsuREgQDeOXLEUIEBLONbcCBCgG0euWAoQoCUca24ECNCNI1csBf4CbYeQxuF66hAAAAAASUVORK5CYII=</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+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+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAA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gIcIBukgABAgQICLAfIECAAAECgYAAB+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><custom-block s="speak %s then %cmdRing in language %s with pitch %n with rate %n with voice %n with volume %n"><block s="reportJoinWords"><list><l>OK, I think I heard </l><block var="last thing spoken"/></list></block><block s="reifyScript"><script></script><list></list></block><l></l><l></l><l></l><l></l><l></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="voice name %'voice'" type="reporter" category="sound"><header></header><code></code><inputs><input type="%n"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>voice</l></list><l>var voices = window.speechSynthesis.getVoices();




if (voice >= 0 && voice < voices.length) {




 return voices[Math.floor(voice)].name;




} else {




 alert("Only " + voices.length + " voices are available. You can't choose voice number " + voice);




}</l></block><list><block var="voice"/></list></block></block></script></block-definition></blocks><variables><variable name="last thing spoken"><l>okay I'm saying something</l></variable><variable name="listening"><bool>true</bool></variable></variables></project>