Created
September 11, 2013 02:42
-
-
Save phelrine/6518751 to your computer and use it in GitHub Desktop.
This file contains 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 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