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 blocks.xml
16 lines (16 loc) · 7.53 KB
/
speak and listen blocks.xml
1
<blocks app="Snap! 4.0, http://snap.berkeley.edu" version="1"><block-definition s="Listen %'respond as heard' then finally %'handle response' but if nothing heard %'handle nothing said' (requires Microsoft speech key)" type="command" category="sensing"><comment x="0" y="0" w="352" collapsed="false">As speech is recognised 'respond as heard' is called with what it thinks it has heard. 'handle response' is called when it htinks the speaking is finished.</comment><header></header><code></code><inputs><input type="%cmdRing"></input><input type="%cmdRing"></input><input type="%cmdRing"></input></inputs><script><custom-block s="run eCraft2Learn command %txt with %mult%s"><l>start_microsoft_speech_recognition</l><list><block var="respond as heard"/><block var="handle response"/><block var="handle nothing said"/></list></custom-block></script></block-definition><block-definition s="Microsoft speech key" type="reporter" category="other"><header></header><code></code><inputs></inputs><script><block s="doReport"><l>Enter your key here</l></block></script></block-definition><block-definition s="Listen then %'handle response' but if error %'handle error'" type="command" category="sensing"><comment x="0" y="0" w="326" collapsed="false">Listens to the microsphone if the browser supports it. If not will contact the Microsoft speech cloud service (key required).</comment><header></header><code></code><inputs><input type="%cmdRing"></input><input type="%cmdRing"></input></inputs><script><custom-block s="run eCraft2Learn command %txt with %mult%s"><l>start_speech_recognition</l><list><block var="handle response"/><block var="handle error"/></list></custom-block></script></block-definition><block-definition s="read URL %'URL' then %'receive contents' or if error %'receive error' using an access key if needed %'key'" type="command" category="sensing"><comment w="383" collapsed="false">Reads the contents of 'URL' and then calls 'receive contents' with that text (in HTML). If there was an error 'receive error' is called instead. 'key' needs only be provided if the URL requires as access key.</comment><header></header><code></code><inputs><input type="%txt"></input><input type="%cmdRing"></input><input type="%cmdRing"></input><input type="%txt"></input></inputs><script><custom-block s="run eCraft2Learn command %txt with %mult%s"><l>read_url</l><list><block var="URL"/><block var="receive contents"/><block var="receive error"/><block var="key"/></list></custom-block></script></block-definition><block-definition s="speak %'message' then %'what to do when finished' with pitch %'pitch' with rate %'rate' with voice %'voice' with volume %'volume' in language %'language code'" type="command" category="sound"><comment w="379" collapsed="false">Speak 'message' and when finished call 'what to do when finished' with 'message'. If specified attributes can be specified. 'rate' can be between .1 (1/10th speed) and 2 (double speed). Voice is a number picking out a voice - call 'Get voice names' to those available in your browser.</comment><header></header><code></code><inputs><input type="%s"></input><input type="%cmdRing"></input><input type="%n"></input><input type="%n"></input><input type="%n"></input><input type="%n"></input><input type="%txt"></input></inputs><script><custom-block s="run eCraft2Learn command %txt with %mult%s"><l>speak</l><list><block var="message"/><block var="pitch"/><block var="rate"/><block var="voice"/><block var="volume"/><block var="language code"/><block var="what to do when finished"/></list></custom-block></script></block-definition><block-definition s="run eCraft2Learn command %'command name' with %'inputs'" type="command" category="other"><header></header><code></code><inputs><input type="%txt"></input><input type="%mult%s"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>function_name</l><l>parameters</l></list><l>if (typeof ecraft2learn === 'object') {







 ecraft2learn.run(function_name, parameters);







} else {







 var script = document.createElement("script");







 script.type = "text/javascript";







 script.src = "https://toontalk.github.io/ai-cloud/ecraft2learn.js";







 script.addEventListener('load', function () {







 ecraft2learn.run(function_name, parameters);







 });







 document.head.appendChild(script);







}</l></block><list><block var="command name"/><block var="inputs"/></list></block></script></block-definition><block-definition s="call eCraft2Learn reporter %'reporter name' with %'inputs'" type="reporter" category="other"><header></header><code></code><inputs><input type="%txt"></input><input type="%mult%s"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>function_name</l><l>parameters</l></list><l>if (typeof ecraft2learn === 'object') {







 return ecraft2learn.run(function_name, parameters);







} else {







 alert("Any eCraft2Learn command must be run before the " + function_name + " reporter.");







 return 0;







}</l></block><list><block var="reporter name"/><block var="inputs"/></list></block></block></script></block-definition><block-definition s="Get voice names" type="reporter" category="sound"><comment w="324" collapsed="false">Some browsers have dozens of voices and some have none. Some voices can speak in other languages -- try speaking a number in another language.</comment><header></header><code></code><inputs></inputs><script><block s="doReport"><custom-block s="call eCraft2Learn reporter %txt with %mult%s"><l>get_voice_names</l><list></list></custom-block></block></script></block-definition><block-definition s="voice name of %'voice number'" type="reporter" category="sound"><comment w="523" collapsed="false">Reports the name of a voice given its number. Note each browser has a different set of voices.</comment><header></header><code></code><inputs><input type="%n"></input></inputs><script><block s="doReport"><custom-block s="call eCraft2Learn reporter %txt with %mult%s"><l>get_voice_name</l><list><block var="voice number"/></list></custom-block></block></script></block-definition><block-definition s="Speak %'message' then %'to do when finished speaking'" type="command" category="sound"><comment w="308" collapsed="false">Speak 'message' using default voice, rate, pitch, etc. When completed 'to do when finished speaking' is called with message.</comment><header></header><code></code><inputs><input type="%txt"></input><input type="%cmdRing"></input></inputs><script><custom-block s="run eCraft2Learn command %txt with %mult%s"><l>speak</l><list><block var="message"/><l></l><l></l><l></l><l></l><l></l><block var="to do when finished speaking"/></list></custom-block></script></block-definition></blocks>