Revision 38936fe1
client/python/hlrc_client/Middleware.py | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import sys |
29 | 29 |
import logging |
30 |
from RobotEmotion import * |
|
31 |
from RobotGaze import * |
|
32 |
from RobotMouth import * |
|
33 |
from RobotAnimation import * |
|
30 |
from .RobotEmotion import *
|
|
31 |
from .RobotGaze import *
|
|
32 |
from .RobotMouth import *
|
|
33 |
from .RobotAnimation import *
|
|
34 | 34 |
|
35 | 35 |
class Middleware: |
36 | 36 |
####################################################################### |
client/python/hlrc_client/MiddlewareROS.py | ||
---|---|---|
25 | 25 |
Excellence Initiative. |
26 | 26 |
""" |
27 | 27 |
|
28 |
from Middleware import * |
|
28 |
from .Middleware import *
|
|
29 | 29 |
|
30 | 30 |
import rospy |
31 | 31 |
import actionlib |
client/python/hlrc_client/MiddlewareRSB.py | ||
---|---|---|
25 | 25 |
Excellence Initiative. |
26 | 26 |
""" |
27 | 27 |
|
28 |
from Middleware import * |
|
28 |
from .Middleware import *
|
|
29 | 29 |
import errno |
30 | 30 |
|
31 | 31 |
import rsb |
... | ... | |
201 | 201 |
|
202 | 202 |
self.logger.debug("speech rpc done") |
203 | 203 |
""" |
204 |
print "WARNING: Not IMPLEMENTED."
|
|
204 |
print("WARNING: Not IMPLEMENTED.")
|
|
205 | 205 |
|
206 | 206 |
|
207 | 207 |
####################################################################### |
client/python/hlrc_client/RobotController.py | ||
---|---|---|
51 | 51 |
if (self.mw.upper() == "RSB"): |
52 | 52 |
self.logger.info("creating new middleware connection via RSB") |
53 | 53 |
try: |
54 |
from MiddlewareRSB import MiddlewareRSB |
|
55 |
except ImportError, e:
|
|
54 |
from .MiddlewareRSB import MiddlewareRSB
|
|
55 |
except ImportError as e:
|
|
56 | 56 |
self.logger.error("failed to import RSB or the necessary data types: {}".format(e)) |
57 | 57 |
sys.exit(errno.EINVAL) |
58 | 58 |
|
... | ... | |
62 | 62 |
elif (self.mw.upper() == "ROS"): |
63 | 63 |
self.logger.info("creating new middleware connection via ROS") |
64 | 64 |
try: |
65 |
from MiddlewareROS import MiddlewareROS |
|
66 |
except ImportError, e:
|
|
65 |
from .MiddlewareROS import MiddlewareROS
|
|
66 |
except ImportError as e:
|
|
67 | 67 |
self.logger.error("failed to import ROS or the necessary data types: {}".format(e)) |
68 | 68 |
sys.exit(errno.EINVAL) |
69 | 69 |
|
client/python/hlrc_client/RobotEmotion.py | ||
---|---|---|
39 | 39 |
# mappings from values to strings and vice versa |
40 | 40 |
__value_as_str = dict(zip([NEUTRAL, HAPPY, SAD, ANGRY, SURPRISED, FEAR], |
41 | 41 |
['neutral', 'happy', 'sad', 'angry', 'surprised', 'fear'])) |
42 |
__str_as_value = dict([(s,v) for v,s in __value_as_str.iteritems()])
|
|
42 |
__str_as_value = dict([(s,v) for v,s in __value_as_str.items()]) |
|
43 | 43 |
|
44 | 44 |
def __init__(self, emotion = NEUTRAL, duration = 1.): |
45 | 45 |
""" constructor |
client/python/hlrc_client/RobotGaze.py | ||
---|---|---|
24 | 24 |
Forschungsgemeinschaft (DFG) in the context of the German |
25 | 25 |
Excellence Initiative. |
26 | 26 |
""" |
27 |
from RobotTimestamp import * |
|
27 |
from .RobotTimestamp import *
|
|
28 | 28 |
|
29 | 29 |
class RobotGaze: |
30 | 30 |
GAZETARGET_ABSOLUTE = 0 |
client/python/hlrc_client/__init__.py | ||
---|---|---|
1 |
from Middleware import Middleware |
|
2 |
from RobotEmotion import RobotEmotion |
|
3 |
from RobotController import RobotController |
|
4 |
from RobotGaze import RobotGaze |
|
5 |
from RobotAnimation import RobotAnimation |
|
6 |
from RobotMouth import RobotMouth |
|
7 |
from RobotTimestamp import RobotTimestamp |
|
1 |
from .Middleware import Middleware |
|
2 |
from .RobotEmotion import RobotEmotion |
|
3 |
from .RobotController import RobotController |
|
4 |
from .RobotGaze import RobotGaze |
|
5 |
from .RobotAnimation import RobotAnimation |
|
6 |
from .RobotMouth import RobotMouth |
|
7 |
from .RobotTimestamp import RobotTimestamp |
client/python/hlrc_client/hlrc_test_gui.py | ||
---|---|---|
182 | 182 |
self.robot_controller.set_speak("Hello my name is flobi. How can i help you?", False) |
183 | 183 |
else: |
184 | 184 |
self.robot_controller.set_speak("invalid button name", False) |
185 |
print "invalid button '%s'" % (button)
|
|
185 |
print("invalid button '%s'" % (button))
|
|
186 | 186 |
|
187 | 187 |
def emotion_button_clicked(self): |
188 | 188 |
button = self.sender().text() |
... | ... | |
203 | 203 |
elif (button == "fear"): |
204 | 204 |
re.value = RobotEmotion.FEAR |
205 | 205 |
else: |
206 |
print "invalid emotion id '%s'" % (button)
|
|
206 |
print("invalid emotion id '%s'" % (button))
|
|
207 | 207 |
return |
208 | 208 |
|
209 | 209 |
self.robot_controller.set_current_emotion(re, False) |
... | ... | |
231 | 231 |
elif (button == "eyebrows lower"): |
232 | 232 |
ra.value = RobotAnimation.EYEBROWS_LOWER |
233 | 233 |
else: |
234 |
print "invalid button '%s'" % (button)
|
|
234 |
print("invalid button '%s'" % (button))
|
|
235 | 235 |
return |
236 | 236 |
|
237 | 237 |
self.robot_controller.set_head_animation(ra, False) |
tts_bridge/mary/mary_tts_bridge/MaryTTSBridge.py | ||
---|---|---|
36 | 36 |
import wave |
37 | 37 |
import os |
38 | 38 |
import pkgutil |
39 |
from MaryTTSClient import * |
|
40 |
from cStringIO import StringIO |
|
39 |
from .MaryTTSClient import * |
|
40 |
try: |
|
41 |
from io import StringIO |
|
42 |
except ImportError: |
|
43 |
from cStringIO import StringIO |
|
41 | 44 |
|
42 | 45 |
class MaryTTSBridge(object): |
43 | 46 |
#_feedback = ttsActionFeedback() |
... | ... | |
110 | 113 |
|
111 | 114 |
return s |
112 | 115 |
|
113 |
def create_phonemes(self, phoneme_str):
|
|
116 |
def create_phonemes(self, phoneme_bytes):
|
|
114 | 117 |
last = 0.0 |
115 | 118 |
plist = [] |
116 | 119 |
|
117 |
sio = StringIO(phoneme_str)
|
|
120 |
sio = StringIO(phoneme_bytes.decode('ascii'))
|
|
118 | 121 |
for line in sio: |
119 | 122 |
if (line[0] != '#'): |
120 | 123 |
phoneme_list = line.split(" ") |
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() |
tts_bridge/mary/mary_tts_bridge/__init__.py | ||
---|---|---|
1 |
from MaryTTSBridge import MaryTTSBridge |
|
1 |
from .MaryTTSBridge import MaryTTSBridge |
Also available in: Unified diff