Revision 836f314c tts_bridge/mary/mary_tts_bridge/MaryTTSClient.py
tts_bridge/mary/mary_tts_bridge/MaryTTSClient.py | ||
---|---|---|
36 | 36 |
|
37 | 37 |
#from MiddlewareROS import * |
38 | 38 |
import sys |
39 |
import httplib, urllib |
|
40 |
import StringIO |
|
39 |
try: |
|
40 |
from http.client import HTTPConnection |
|
41 |
from urllib.parse import urlencode |
|
42 |
except ImportError: # Python 2 |
|
43 |
from httplib import HTTPConnection |
|
44 |
from urllib import urlencode |
|
41 | 45 |
import wave |
42 | 46 |
import ctypes |
43 | 47 |
import wave |
... | ... | |
102 | 106 |
"VOICE": self.voice, |
103 | 107 |
} |
104 | 108 |
|
105 |
params = urllib.urlencode(raw_params)
|
|
109 |
params = urlencode(raw_params) |
|
106 | 110 |
headers = {} |
107 | 111 |
|
108 | 112 |
#conn.set_debuglevel(5) |
109 | 113 |
#open connection to mary server |
110 |
conn = httplib.HTTPConnection(self.tts_host, self.tts_port)
|
|
114 |
conn = HTTPConnection(self.tts_host, self.tts_port) |
|
111 | 115 |
|
112 | 116 |
conn.request("POST", "/process", params, headers) |
113 | 117 |
response = conn.getresponse() |
114 | 118 |
|
115 | 119 |
if response.status != 200: |
116 |
print response.getheaders()
|
|
120 |
print(response.getheaders())
|
|
117 | 121 |
conn.close() |
118 | 122 |
raise RuntimeError("{0}: {1}".format(response.status,response.reason)) |
119 | 123 |
return response.read() |
Also available in: Unified diff