2016-11-23 05:53:03 +00:00
|
|
|
# Your browser must support async/await and speech synthesis
|
|
|
|
# to run this example.
|
|
|
|
|
2016-11-05 09:54:18 +00:00
|
|
|
sleep = (ms) ->
|
|
|
|
new Promise (resolve) ->
|
|
|
|
window.setTimeout resolve, ms
|
2016-11-04 21:20:27 +00:00
|
|
|
|
2016-11-06 19:26:34 +00:00
|
|
|
say = (text) ->
|
2016-11-23 05:53:03 +00:00
|
|
|
window.speechSynthesis.cancel()
|
2016-11-06 19:26:34 +00:00
|
|
|
window.speechSynthesis.speak new SpeechSynthesisUtterance text
|
|
|
|
|
2016-11-06 10:30:01 +00:00
|
|
|
countdown = (seconds) ->
|
2016-11-05 09:54:18 +00:00
|
|
|
for i in [seconds..1]
|
2016-11-23 05:53:03 +00:00
|
|
|
say i
|
2016-11-06 10:30:01 +00:00
|
|
|
await sleep 1000 # wait one second
|
2016-11-06 19:26:34 +00:00
|
|
|
say "Blastoff!"
|
2016-11-06 10:30:01 +00:00
|
|
|
|
2016-11-23 05:53:03 +00:00
|
|
|
countdown 3
|