-
Couldn't load subscription status.
- Fork 3
Merge changes from Hanson Robotics #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
e280495
6546527
af7f5b5
efb8988
f26496d
da3d66c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| <?xml version="1.0"?> | ||
| <package> | ||
| <name>itf_talk</name> | ||
| <version>0.0.0</version> | ||
| <version>0.0.2</version> | ||
| <description>The itf_talk package</description> | ||
|
|
||
| <!-- One maintainer tag required, multiple allowed, one person per tag --> | ||
| <!-- Example: --> | ||
| <!-- <maintainer email="[email protected]">Jane Doe</maintainer> --> | ||
| <maintainer email="alex@todo.todo">alex</maintainer> | ||
| <maintainer email="alex@yutani.nl">Alex van der Peet</maintainer> | ||
|
|
||
|
|
||
| <!-- One license tag required, multiple allowed, one license per tag --> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| import os | ||
| import rospy | ||
| import urllib, pycurl | ||
| from threading import Thread | ||
| from std_msgs.msg import String, Float32, Bool | ||
| from std_msgs.msg import String, Float64, Bool | ||
| import subprocess | ||
| import pydub | ||
| import math | ||
|
|
@@ -14,17 +15,18 @@ | |
| class ITFTalker(Thread): | ||
| NODE_NAME = 'itf_talker' | ||
| pub = rospy.Publisher('itf_next_sentence', String, queue_size=1) | ||
| pub_speech_strength = rospy.Publisher('speech_strength', Float32, queue_size=1) | ||
| pub_speech_strength = rospy.Publisher('/dmitry/jaw_controller/command', Float64, queue_size=1) | ||
| pub_speech_active = rospy.Publisher('speech_active', Bool, queue_size=1) | ||
| soundfile = None | ||
| rms_params = {"scale": 1.0/5000, "min": 0.0, "max": 1.0} | ||
| gletplayer = None | ||
| stop_request_received = False | ||
| jaw_inactive = True | ||
|
|
||
| def __init__(self): | ||
| Thread.__init__(self) | ||
| rospy.init_node(ITFTalker.NODE_NAME, log_level=rospy.INFO) | ||
| rospy.Subscriber("itf_talk", String, self.callback) | ||
| rospy.Subscriber("chatbot_responses", String, self.callback) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be named back as it will break changes with existing code. The topic would ideally have name like "speech" E.g. see "speech (std_msgs/String)" on the Nao robot page. |
||
| rospy.Subscriber("itf_talk_stop", String, self.callback_stop) | ||
|
|
||
| pyglet.clock._get_sleep_time = pyglet.clock.get_sleep_time | ||
|
|
@@ -85,13 +87,15 @@ def speakSpeechFromText(self, phrase): | |
| googleSpeechURL = self.getGoogleSpeechURL(section) | ||
| print "Downloading " + googleSpeechURL + " to " + "tts" + str(index).zfill(index) + ".mp3\n" | ||
| self.downloadFile(googleSpeechURL,"tts" + str(index).zfill(index) + ".mp3") | ||
| fileName = "tts" + str(index).zfill(index) | ||
| os.system("avconv -y -i "+fileName+".mp3 "+ fileName+".wav" ) | ||
| print index, section | ||
|
|
||
| totalDuration = 0 | ||
|
|
||
| for index, section in enumerate(phraseSections): | ||
| fileName = 'tts' + str(index).zfill(index) + '.mp3' | ||
| dubsegment = pydub.AudioSegment.from_mp3(fileName) | ||
| fileName = 'tts' + str(index).zfill(index) + '.wav' | ||
| dubsegment = pydub.AudioSegment.from_wav(fileName) | ||
| totalDuration += dubsegment.__len__() | ||
| dubsegment = None | ||
|
|
||
|
|
@@ -109,9 +113,10 @@ def speakSpeechFromText(self, phrase): | |
| ITFTalker.pub_speech_active.publish(True) | ||
|
|
||
| for index, section in enumerate(phraseSections): | ||
| fileName = 'tts' + str(index).zfill(index) | ||
|
|
||
| fileName = fileName + '.wav' | ||
| if (not self.stop_request_received): | ||
| fileName = 'tts' + str(index).zfill(index) + '.mp3' | ||
| print 'Calling SoundPlayer with parameter ' + fileName | ||
|
|
||
| self.play(fileName) | ||
|
|
||
|
|
@@ -142,7 +147,15 @@ def hit(self, rms): | |
| p = self.rms_params | ||
| jaw_coeff = min(max(math.sqrt(rms * p["scale"]), p["min"]), p["max"]) | ||
|
|
||
| self.pub_speech_strength.publish(jaw_coeff) | ||
| if jaw_coeff > 0: | ||
| jaw_coeff = jaw_coeff*0.4-0.15; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The jaw_coeff value, published to speech strength should always be between 0.0 - 1.0. Does this change that? The receiver should alter it to suit their needs. |
||
| self.pub_speech_strength.publish(jaw_coeff) | ||
| self.jaw_inactive = False | ||
| else: | ||
| if not self.jaw_inactive: | ||
| self.pub_speech_strength.publish(jaw_coeff) | ||
| self.jaw_inactive = True | ||
|
|
||
|
|
||
| # Copy pau expression message stored during handle_face_in(), | ||
| # modify jaw and publish. | ||
|
|
@@ -158,6 +171,7 @@ def stop(self): | |
|
|
||
| def play(self, filename): | ||
| self.stop() | ||
|
|
||
| self.soundfile = SoundFile(filename) | ||
| self.soundfile.on_playmore = self.hit # Set callback | ||
| self.soundfile.play() | ||
|
|
@@ -175,7 +189,7 @@ def callback_stop(self, data): | |
| talker = ITFTalker() | ||
|
|
||
| talker.start() | ||
| rospy.loginfo("{0} started, listening for text input on topic itf_talk...".format(ITFTalker.NODE_NAME)) | ||
| rospy.loginfo("{0} started, listening for text input on topic chatbot_repsonses...".format(ITFTalker.NODE_NAME)) | ||
|
|
||
| rospy.spin() | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be changed back to how it was; its bad to hard code the topic name to produce data for a particular system.
The dmitry jaw controller should instead subscribe to the topic speech_strength.