Skip to content

Instantly share code, notes, and snippets.

@takuya
Created December 14, 2013 07:43
Show Gist options
  • Save takuya/7956585 to your computer and use it in GitHub Desktop.
Save takuya/7956585 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# coding:utf-8
require 'open-uri'
require 'json'
require 'base64'
str = ARGV.shift
uri = "http://rospeex.ucri.jgn-x.jp/nauth_json/jsServices/VoiceTraSS?method=speak&params[]=ja&params[]=#{URI.encode(str)}&params[]=*&params[]=audio/x-wav&_=1386261073492"
obj = JSON.parse(open(uri).read)
data = obj["result"]["audio"]
open("#{str}.wav", "w"){|f| f.write(Base64.decode64(data)) }
`ffmpeg -i '#{str}.wav' -c:a libfdk_aac -b:a 256k '#{str}.m4a' `
`rm #{str}.wav`
`afplay '#{str}.m4a' `
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment