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