Skip to content

Instantly share code, notes, and snippets.

@phelrine
Created September 11, 2013 02:42
Show Gist options
  • Save phelrine/6518751 to your computer and use it in GitHub Desktop.
Save phelrine/6518751 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import requests
import json
import base64
URL = 'http://rospeex.ucri.jgn-x.jp/nauth_json/jsServices/VoiceTraSS'
def post(text):
params = json.dumps({'method': 'speak', 'params': ['ja', text, '*', 'audio/x-wav']})
return requests.post(URL, data = params)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('text')
parser.add_argument('wavfile')
args = parser.parse_args()
response = post(args.text)
ret = response.json()
if ret['error']:
print 'error'
exit(1)
with open(args.wavfile, 'w') as f:
f.write(base64.decodestring(ret['result']['audio']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment