def onMessage(self, mid=None, author_id=None, message=None, message_object=None, thread_id=None, thread_type=ThreadType.USER, ts=None, metadata=None, msg=None): # igrone your own message if (author_id == self.uid): return self.markAsDelivered(thread_id, message_object.uid) self.delay() self.markAsRead(thread_id) self.delay() #handle name = self.get_name_by_user_id(author_id) text = message_object.text log.info('{}: {}'.format(name, text)) text_to_speech.say(name + ' nói ' + text)
def assistant(command): if "price of" in command: regex = re.search("price of (.*)", command) if regex: item = regex.group(1) get_marketvalue(item) print("Done!") if "quantity of" in command: regex = re.search("quantity of (.*)", command) if regex: item = regex.group(1) get_quantity(item) print("Done!") if "show me" in command: regex = re.search("show me (.*)", command) if regex: item = regex.group(1) webbrowser.open("https://goblineer.tk/item/" + item.replace(" ", "+")) print("Done!") if "exit" == command: tts.say("Goodbye!") sys.exit() if "dog" in command: webbrowser.open( get_data.load_json("https://dog.ceo/api/breeds/image/random") ["message"]) return
def get_quantity(item_to_search): found = False for data in mv_names: if data["name"].upper() == item_to_search.upper(): quantity = data["quantity"] tts.say("The quantity of " + data["name"] + " is " + num2words(quantity)) found = True break if not found: tts.say("Item not found.")
def get_marketvalue(item_to_search): found = False for data in mv_names: if data["name"].upper() == item_to_search.upper(): marketvalue = float(data["marketvalue"]) marketvalue_gold = trunc(marketvalue) marketvalue_silver = trunc( round(marketvalue - marketvalue_gold, 2) * 100) tts.say("The marketvalue of " + data["name"] + " is " + num2words(marketvalue_gold) + " gold and " + num2words(marketvalue_silver) + " silver") found = True break if not found: tts.say("Item not found.")
def run_without_mic(): while True: item_to_search = input("Item to search: ") found = False if item_to_search == "exit": sys.exit() for data in mv_names: if data["name"].upper() == item_to_search.upper(): marketvalue = float(data["marketvalue"]) marketvalue_gold = trunc(marketvalue) marketvalue_silver = trunc( round(marketvalue - marketvalue_gold, 2) * 100) tts.say("The marketvalue of " + data["name"] + " is " + num2words(marketvalue_gold) + " gold and " + num2words(marketvalue_silver) + " silver") found = True break if not found: tts.say("Item not found.")
def on_symbol_clicked(self, symbol, event): if event.button == LEFT_BUTTON: text_to_speech.say(symbol.label) elif event.button == RIGHT_BUTTON: SymbolEditorDialog(self.parent, symbol)
def cmd_dispatcher(sentence): if sentence in STOP_LISTENING_HOTWORDS: return True # setup sentence = str.lower(sentence) words = sentence.split(' ') features_controller(sentence, words) def init(): # starting with speech searches # cmd_dispatcher("testing") pass def controller(): init() while True: if cmd_dispatcher(get_text_from_speech()): break if __name__ == '__main__': say(f'Kiara is alive') controller()
print("Number of words: " + str(len(boxes))) if (nWordsPrev != len(boxes)): nWordsPrev = len(boxes) #text_to_speech.say(str(len(boxes)) + " words have been found") #text_to_speech.say(str(len(boxes)) + " words have been found") errorMargin = 0.35 if (len(boxes) >= readThreshold and batchIndex == len(batch) and batchAvg(batch) / len(boxes) < 1 + errorMargin and batchAvg(batch) / len(boxes) > 1 - errorMargin): print("start reading") print(crop) cropImage = noBox[crop[0][1]:crop[1][1], crop[0][0]:crop[1][0]] cv2.imwrite("currentFrame.png", cropImage) text_to_speech.say("The text says: ") convert_to_text.convert("currentFrame.png") if (batchIndex == len(batch)): print(batchAvg(batch)) batchIndex = 0 batch[0] = len(boxes) else: batch[batchIndex] = len(boxes) batchIndex += 1 key = cv2.waitKey(1) & 0xFF # if the `q` key was pressed, break from the loop if key == ord("q"): break
import sys ########################## Main ########################## # first argument: phrase # second argument: who responds # Nao as default import speech_to_text_app as stt import text_to_speech as tts import nlc voice = sys.argv[1] #TODO: if no phrase given, start detecting speech phrase = sys.argv[2] global HILTON_CLASSIFIER = "341781x90-nlc-7639" # ask watson what type of phrase is this topClass = nlc.find_class(HILTON_CLASSIFIER, phrase) # Make the robot say the phrase tts.set_voice(voice) tts.say(phrase) # say the veredict veredict = 'The class is. ' + str(topClass['class_name']) + '. With confidence of. ' + str(topClass['confidence']) tts.say(veredict)