Created
March 20, 2014 22:16
-
-
Save illucent/9675115 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # coding: UTF-8 | |
| # ARGV[0] - string with text, need to be spoken | |
| # ARGV[1] - filename for new wav file | |
| require 'mechanize' | |
| # retrieve web page with tts | |
| a = Mechanize.new | |
| req = a.get 'http://www2.research.att.com/~ttsweb/tts/demo.php' | |
| # get the form | |
| form = req.forms[0] | |
| # replace with parameter | |
| form['txt'] = ARGV[0] | |
| # set german female voice | |
| form['voice'] = 'reiner' # use 'klara' for female voice | |
| # submit the form | |
| ret = form.submit | |
| # write sound to wav file | |
| File.open(ARGV[1]+'.wav', 'w') {|f| f.write(ret.body) } | |
| # create gsm file for Asterisk | |
| %x[ sox #{ARGV[1]}.wav -r 8000 #{ARGV[1]}.gsm resample -ql ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment