except: text = 'Null' tableToPublish[0] = intent tableToPublish[1] = str(number) tableToPublish[2] = str(whichCommands) tableToPublish[3] = colour tableToPublish[4] = howFast tableToPublish[5] = str(confidence) tableToPublish[6] = direction tableToPublish[7] = whichFunction tableToPublish[8] = text print "intent: " + intent except: tableToPublish[0] = "NULL" print('\n' "Intent: Null" '\n') msg_to_send= Num() msg_to_send.some_strings = tableToPublish rospy.loginfo(msg_to_send) print (" ") pub.publish(msg_to_send) rate.sleep()
def recorderResponse(data): global fileNumber global pub pub = rospy.Publisher('chatter', Num, queue_size=10) fileNumber = data.data path = '../Sounds/file' + str(fileNumber) + '.wav' dataDict = queryAudio(path,key) try: intent= dataDict["outcomes"][0]["intent"] #print ("Try intent") try: number=dataDict["outcomes"][0]["entities"]['number'][0]['value'] #print ("Try number") if(number): if not(number.isdigit()): number = textToNumber(number) #print ("Konwersja number") except: #print ("Except number") if(str(intent) == 'Zmiana_kontroli'): #print("Zmiana kontroli ale brak numberu") number = 0 else: number = 1 try: whichCommands = dataDict["outcomes"][0]["entities"]['ktore'][0]['value'] if (whichCommands): #print("Ktore komendy: " + str(whichCommands)) whichCommands = czyKoncoweKomendy(str(whichCommands)) else: whichCommands = 3 #ostatnie except: whichCommands = 3 #print ("Bląd przy whichCommands") try: howFast = dataDict["outcomes"][0]["entities"]['howFast'][0]['value'] except: howFast = 'normalnie' try: colour = dataDict["outcomes"][0]["entities"]['colour'][0]['value'] except: colour = 'Brak colouru' if(intent == 'Zmiencolour'): colour = 'kolejny' try: confidence= dataDict["outcomes"][0]["confidence"] confidence = confidence * 100 except: confidence = 'Null' try: direction= dataDict["outcomes"][0]["entities"]['direction'][0]['value'] except: direction = 'Null' try: whichFunction= dataDict["outcomes"][0]["entities"]['whichFunction'][0]['value'] except: whichFunction = 'Null' try: "Print text" text= dataDict["outcomes"][0]["_text"] print text except: text = 'Null' tableToPublish[0] = intent tableToPublish[1] = str(number) tableToPublish[2] = str(whichCommands) tableToPublish[3] = colour tableToPublish[4] = howFast tableToPublish[5] = str(confidence) tableToPublish[6] = direction tableToPublish[7] = whichFunction tableToPublish[8] = text print "intent: " + intent except: tableToPublish[0] = "NULL" print('\n' "Intent: Null" '\n') msg_to_send= Num() msg_to_send.some_strings = tableToPublish rospy.loginfo(msg_to_send) print (" ") pub.publish(msg_to_send) rate.sleep()
whichFunction = 'Null' try: "Print text" text = dataDict["outcomes"][0]["_text"] print text except: text = 'Null' tableToPublish[0] = intent tableToPublish[1] = str(number) tableToPublish[2] = str(whichCommands) tableToPublish[3] = colour tableToPublish[4] = howFast tableToPublish[5] = str(confidence) tableToPublish[6] = direction tableToPublish[7] = whichFunction tableToPublish[8] = text print "intent: " + intent except: tableToPublish[0] = "NULL" print('\n' "Intent: Null" '\n') msg_to_send = Num() msg_to_send.some_strings = tableToPublish rospy.loginfo(msg_to_send) print(" ") pub.publish(msg_to_send) rate.sleep()
def recorderResponse(data): global fileNumber global pub pub = rospy.Publisher('chatter', Num, queue_size=10) fileNumber = data.data path = '../Sounds/file' + str(fileNumber) + '.wav' dataDict = queryAudio(path, key) try: intent = dataDict["outcomes"][0]["intent"] #print ("Try intent") try: number = dataDict["outcomes"][0]["entities"]['number'][0]['value'] #print ("Try number") if (number): if not (number.isdigit()): number = textToNumber(number) #print ("Konwersja number") except: #print ("Except number") if (str(intent) == 'Zmiana_kontroli'): #print("Zmiana kontroli ale brak numberu") number = 0 else: number = 1 try: whichCommands = dataDict["outcomes"][0]["entities"]['ktore'][0][ 'value'] if (whichCommands): #print("Ktore komendy: " + str(whichCommands)) whichCommands = czyKoncoweKomendy(str(whichCommands)) else: whichCommands = 3 #ostatnie except: whichCommands = 3 #print ("Bląd przy whichCommands") try: howFast = dataDict["outcomes"][0]["entities"]['howFast'][0][ 'value'] except: howFast = 'normalnie' try: colour = dataDict["outcomes"][0]["entities"]['colour'][0]['value'] except: colour = 'Brak colouru' if (intent == 'Zmiencolour'): colour = 'kolejny' try: confidence = dataDict["outcomes"][0]["confidence"] confidence = confidence * 100 except: confidence = 'Null' try: direction = dataDict["outcomes"][0]["entities"]['direction'][0][ 'value'] except: direction = 'Null' try: whichFunction = dataDict["outcomes"][0]["entities"][ 'whichFunction'][0]['value'] except: whichFunction = 'Null' try: "Print text" text = dataDict["outcomes"][0]["_text"] print text except: text = 'Null' tableToPublish[0] = intent tableToPublish[1] = str(number) tableToPublish[2] = str(whichCommands) tableToPublish[3] = colour tableToPublish[4] = howFast tableToPublish[5] = str(confidence) tableToPublish[6] = direction tableToPublish[7] = whichFunction tableToPublish[8] = text print "intent: " + intent except: tableToPublish[0] = "NULL" print('\n' "Intent: Null" '\n') msg_to_send = Num() msg_to_send.some_strings = tableToPublish rospy.loginfo(msg_to_send) print(" ") pub.publish(msg_to_send) rate.sleep()