Skip to content

Instantly share code, notes, and snippets.

@mvilrokx
Created December 9, 2012 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mvilrokx/4245721 to your computer and use it in GitHub Desktop.
Save mvilrokx/4245721 to your computer and use it in GitHub Desktop.
Iris: Function called when a speech recognition result is received.
# Function called when a speech recognition result is received.
speechChange = (e) ->
# Flow
# 1. pass received text to service that can interpret the text (using WolframAlpha right now)
# 2. when this service returns, show results of this service in the stream
e.preventDefault()
if e.type == 'webkitspeechchange' && e.originalEvent.results
topResult = e.originalEvent.results[0]
adjustStream(topResult.utterance)
# submit the form to the proxy service
$.get(
$('#process_speech').attr('action'),
$('#process_speech').serialize(),
# (data, textStatus, jqXHR) -> adjustStream(data.queryresult.pod[1].subpod.plaintext),
(data, textStatus, jqXHR) ->
if data.queryresult.success == 'true'
if data.queryresult.pod[1].subpod instanceof Array
adjustStream(img(data.queryresult.pod[1].subpod[0].img))
else
adjustStream(img(data.queryresult.pod[1].subpod.img))
else
adjustStream("I'm sorry, I didn't understand, please try again")
"json"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment