Skip to content

Instantly share code, notes, and snippets.

@sfgeorge
Created August 3, 2011 16:06
Show Gist options
  • Save sfgeorge/e941128659baf557ffd2 to your computer and use it in GitHub Desktop.
Save sfgeorge/e941128659baf557ffd2 to your computer and use it in GitHub Desktop.
double quotes should be escaped in #speak
# Single-quotes work just fine...
duration_of { speak "<speak xmlns='http://www.w3.org/2001/10/synthesis' version='1.0' xml:lang='en-US'> <voice name='Paul'> <prosody rate='1.0'>Howdy, stranger. How are you today?</prosody> </voice> </speak>", :engine => :unimrcp }
# DEBUG agi: >>> EXEC MRCPSynth "<speak xmlns='http://www.w3.org/2001/10/synthesis' version='1.0' xml:lang='en-US'> <voice name='Paul'> <prosody rate='1.0'>Howdy, stranger. How are you today?</prosody> </voice> </speak>"
# DEBUG agi: <<< 200 result=0
# => 3.279441933 # The message is about 3 seconds long.
# Double-quotes don't work...
duration_of { speak '<speak xmlns="http://www.w3.org/2001/10/synthesis" version="1.0" xml:lang="en-US"> <voice name="Paul"> <prosody rate="1.0">Howdy, stranger. How are you today?</prosody> </voice> </speak>', :engine => :unimrcp }
# DEBUG agi: >>> EXEC MRCPSynth "<speak xmlns="http://www.w3.org/2001/10/synthesis" version="1.0" xml:lang="en-US"> <voice name="Paul"> <prosody rate="1.0">Howdy, stranger. How are you today?</prosody> </voice> </speak>"
# DEBUG agi: <<< 200 result=0
# => 0.186863764 # The message wasn't said at all.
# But if we were to double-escape quotes, we'd be in business...
message = %q{EXEC MRCPSynth "<speak xmlns=\\\\\\"http://www.w3.org/2001/10/synthesis\\\\\\" version=\\\\\\"1.0\\\\\\" xml:lang=\\\\\\"en-US\\\\\\"> <voice name=\\\\\\"Paul\\\\\\"> <prosody rate=\\\\\\"1.0\\\\\\">Howdy, stranger. How are you today?</prosody> </voice> </speak>"}
duration_of { p raw_response message }
# DEBUG agi: >>> EXEC MRCPSynth "<speak xmlns=\\\"http://www.w3.org/2001/10/synthesis\\\" version=\\\"1.0\\\" xml:lang=\\\"en-US\\\"> <voice name=\\\"Paul\\\"> <prosody rate=\\\"1.0\\\">Howdy, stranger. How are you today?</prosody> </voice> </speak>"
# DEBUG agi: <<< 200 result=0
# "200 result=0\n"
# => 3.210058733 # The message was played
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment