Skip to content

Instantly share code, notes, and snippets.

@zlu
Created June 25, 2009 20:21
Show Gist options
  • Save zlu/136137 to your computer and use it in GitHub Desktop.
Save zlu/136137 to your computer and use it in GitHub Desktop.
#Method to create files themselves, takes the texts, creates the file and returns the filename
def surveys_create_file(text)
case engine
#Cepstral speech engine, see http://www.cepstral.com, as it requires a license
when "cepstral"
filename = '/var/lib/asterisk/sounds' + new_guid + ".wav"
system("swift -o #{filename} -p audio/channels=1,audio/sampling-rate=8000 '#{text}'")
#Festival OSS speech engine
#on CentOS v5.0+ simply do a yum install festival
when "festival"
filename = '/var/lib/asterisk/sounds' + new_guid + ".ulaw"
system("echo #{text} | text2wave -o #{filename} -otype ulaw")
#Currently uses the built in OSX TTS engine 'say' which is part of PlainTalk
#http://en.wikipedia.org/wiki/Plaintalk
when "osx_say"
filename = '/var/lib/asterisk/sounds' + new_guid
system("say -v Alex} -o #{filename}.aiff #{text}")
system("sox #{filename}.aiff -r 8000 -t ul #{filename}.ulaw")
end
return filename
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment