def __init__(self): self.lc=lcm.LCM() self.filename = os.path.dirname(os.path.abspath(__file__))+'/../data/quad_corpus.txt' self.bag = bag_of_words(self.filename, 1) self.pub = rospy.Publisher('/ar_marker_switch', String) self.speechPub = rospy.Publisher('/text_to_speech', String) self.subscription = self.lc.subscribe("CHOICE", self.lcmCallback) rospy.Subscriber("/speech_results", Speech, self.rosCallback)
def lcmCallback(self, channel, data): print data print self.lastMsg corpusFile = open(self.filename,'a') for i in self.lastMsg.msg: toAdd = i+" "+data.replace("\00", "")+"\n" corpusFile.write(toAdd) corpusFile.close() self.bag = bag_of_words(self.filename, 1) self.pub.publish(data.replace("\00", ""))