IBM Watson text-to-speechを試す(POST版)のRuby版
textToSpeechPost.rb
require 'rest-client'
require 'json'
user = "ユーザID"
pass = "パスワード"
url = "https://#{user}:#{pass}@stream.watsonplatform.net/text-to-speech/api/v1/synthesize"
accept = "audio/wav"
voice = "ja-JP_EmiVoice"
ifile = "input.json"
ofile = "output.wav"
json = JSON.load(File.open(ifile).read).to_json
res = RestClient.post url, json, {content_type: :json, accept: accept, params:{voice:voice}}
IO.write(ofile,res.body)
input.json
{ "text" : "これはTextToSpeechのRubyPOSTバージョンです。" }