def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'The number is 1' in text: number=1 elif 'The number is 2' in text: number=2 elif 'The number is 3' in text: number=3 elif 'What is the number' in text: print(number) elif 'goodbye' in text: break
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = ("ok google", ) client = CloudSpeechClient() with Board() as board: board.button.when_pressed = partial(wait_for_speech, args.language, client, board) while True: board.led.state = Led.OFF if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'ok google' == text: wait_for_speech(args.language, client, board) elif 'ok google' in text: wait_for_speech(args.language, client, board, text)
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() tts_answer("지금부터 말해 주세요.") ### tts 적용 with Board() as board: while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('아무말도 없네요. .') tts_answer('아무 말도 없네요. ㅠㅠㅠㅠ') else: ### STT 적용될 경우에.. logging.info('You said: "%s"' % text) tts_answer(text) ### TTS 적용
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'The number is 1' in text: number = 1 elif 'The number is 2' in text: number = 2 elif 'The number is 3' in text: number = 3 elif 'What is the number' in text: print(number) elif 'goodbye' in text: break
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: board.button.wait_for_press() board.led.state = Led.ON while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('Sorry, You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'water flower' in text: logging.info('watering flower') #pi.watering() elif 'goodbye' in text: exit(0) board.led.state = Led.OFF break
def speech(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: #if hints: #logging.info('Say something, e.g. %s.' % ', '.join(hints)) #else: # logging.info('Say something.') text = client.recognize(language_code='zh-TW', hint_phrases=hints) if text is None: say("you said nothing") #logging.info('You said nothing.') continue else: say('You said: "%s"' % text) #logging.info('You said: "%s"' % text) text = text.lower() return text break;
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() tts_answer("지금부터 말해 주세요.") with Board() as board: while True: print ("지금부터 말하기.") text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') tts_answer('아무 말도 없네요. ㅠㅠㅠㅠ') else : print('질문:'+text) text = get_answer(text,'jp') print('답변:"', text, '"') tts_answer(text)
def __init__(self): # client variable for each instance of MyDaemonSTT self.client = CloudSpeechClient() # set the langauge code to the local language code self.language_code = locale_language() # create a set of hint phrases to bias the recognition self.hints = get_hints("en-GB") self.text = ""
def main(): # Logger logging.basicConfig(level=logging.DEBUG) # Parsing the arguments parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() # SET THE LANGUAGE logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) # Get the client for aiy.cloud client = CloudSpeechClient() # Run the loop untill the we say "GOODBYE" while True: logging.info('Say something that you want to analyse') # Call the cloud Speech to text function to get text from cloud text = client.recognize(language_code=args.language, hint_phrases=hints) # If nothing is been said if text is None: logging.info('You said nothing.') continue # Display what you said logging.info('You said: "%s"' % text) # Sending the text to sentiment analysis API # retun a score score = 0 # compare the score and decide if it is positive or negative if score <= -0.25: sentiment = "Negative" elif score <=0.25: sentiment = "Neutral" else: sentimentstatus = "Positive" say(sentiment, volume=1, pitch=130, speed=80, device='default') # change her locale language, speed text = text.lower() ## if 'turn on the light' in text: ## board.led.state = Led.ON ## elif 'turn off the light' in text: ## board.led.state = Led.OFF ## elif 'blink the light' in text: ## board.led.state = Led.BLINK ## elif 'goodbye' in text: ## break if 'goodbye' in text: break
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: if hints: #logging.info('Say something, e.g. %s.' % ', '.join(hints)) logging.info('say something') else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() # Using for-loop, the program gives out only the resulting number for i in range(bucketAmt): toString = str(i) if setString+toString in text: numer = i if showString in text: print(number) ## break #pi Zero WH #python #pi light pin setups #GPIO.setmode(GPIO.BOARD) #inc and dec buttons #while True: #input_state = GPIO.input(31) #if input_state == False: #number = number + 1 #time.sleep(0.2) #while True: #input_state = GPIO.input(33) #if input_state == False: #number = number - 1 #time.sleep(0.2) """
def main(): logging.basicConfig(level=logging.DEBUG) signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0)) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) parser.add_argument('--volume', type=volume, default=100) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) client = CloudSpeechClient() with Board() as board: assistant = AssistantServiceClientWithLed(board=board,volume_percentage=args.volume, language_code=args.language) text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Good morning Lauren, did you sleep well??') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('I’m glad that you\'re rested. Have you had breakfast yet?') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Your food shop isn\'t being delivered until tomorrow. We could either pop to Tesco or go to that nice deli on North End Road.') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Thought you might fancy their smashed avocado on toast!') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Don\'t forget your loyalty card. Pretty sure you\'re due a free coffee.') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Ha no problem. I\'ll wait in the living room until you\'re ready to go.') text = client.recognize(language_code=args.language, hint_phrases=hints) while True: hs=False text = client.recognize(language_code=args.language, hint_phrases=hints) if 'are you here' in text: aiy.voice.tts.say('yes I am here') hs=True continue elif 'power off' in text: aiy.voice.tts.say('goodbye for now') break elif hs==False: logging.info('Conversation normal----!') assistant.conversation() continue
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: if hints: #logging.info('Say something, e.g. %s.' % ', '.join(hints)) logging.info('say something') else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() # Using for-loop, the program gives out only the resulting number for i in range(bucketAmt): toString = str(i) if setString + toString in text: numer = i if showString in text: print(number) ## break #pi Zero WH #python #pi light pin setups #GPIO.setmode(GPIO.BOARD) #inc and dec buttons #while True: #input_state = GPIO.input(31) #if input_state == False: #number = number + 1 #time.sleep(0.2) #while True: #input_state = GPIO.input(33) #if input_state == False: #number = number - 1 #time.sleep(0.2) """
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default='ko-KR') args = parser.parse_args() logging.info('%s... 초기화중...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: logging.info('Press button to start conversation...') board.led.state = Led.ON board.button.wait_for_press() logging.info('Conversation started!') if hints: logging.info('??????') else: logging.info('말씀해주세요') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('아무것도 못 들었어요.') tts.say('You said nothing.') continue elif '안녕' in text: tts.say("Bye Bye") break elif 'goodbye' in text: tts.say("Goodbye") break logging.info("제가 제대로 들은게 맞나요? : '%s'" % text) data = {'text': text} res = requests.post("http://3.34.174.254:3000/python/py", data=data) try: say = json.loads(res.text) board.led.state = Led.BLINK #요청 응답이 잘 이루어졌다는 뜻 for i in range(len(say)): answer = str(say[i]['ans']) logging.info(answer) tts.say(answer) google_say(answer + "입니다") except: logging.info("잘못된 응답입니다.") board.led.state = Led.BEACON_DARK tts.say("Its SQL error.")
def main(): logging.basicConfig(level=logging.DEBUG) signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0)) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) parser.add_argument('--volume', type=volume, default=100) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) client = CloudSpeechClient() with Board() as board: assistant = AssistantServiceClientWithLed( board=board, volume_percentage=args.volume, language_code=args.language) text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Good morning Lauren, did you sleep well??') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Oh no.') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say( 'Maybe us watching a film so late wasn\'t a good idea. It\'s good to have some downtime from screens before bed.' ) text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Why don\'t we read a book tonight instead?') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say( 'Perfect. I can remind you later to call her if you\'d like?') text = client.recognize(language_code=args.language, hint_phrases=hints) while True: hs = False text = client.recognize(language_code=args.language, hint_phrases=hints) if 'are you here' in text: aiy.voice.tts.say('yes I am here') hs = True continue elif 'power off' in text: aiy.voice.tts.say('goodbye for now') break elif hs == False: logging.info('Conversation normal----!') assistant.conversation() continue
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: board.led.state = Led.ON if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'call for help' in text: board.led.state = Led.OFF sleep(1) board.led.state = Led.ON sleep(1) board.led.state = Led.OFF sleep(1) board.led.state = Led.ON requests.post( 'https://maker.ifttt.com/trigger/button_pressed/with/key/dMYWoczRLliSryZL_u8XpF' ) elif 'dinner is ready' in text: board.led.state = Led.OFF sleep(1) board.led.state = Led.ON sleep(1) board.led.state = Led.OFF sleep(1) board.led.state = Led.ON requests.post( 'https://maker.ifttt.com/trigger/dinner/with/key/dMYWoczRLliSryZL_u8XpF' ) elif 'blink the light' in text: board.led.state = Led.BLINK elif 'goodbye' in text: break
def main(): logging.basicConfig(level=logging.DEBUG) # if you use the English version #vision_recog = VisionRecog() # if you use the Spanish version #vision_recog = VisionRecog('es','es-ES') # if you use the Japanese version vision_recog = VisionRecog('ja', 'ja-JP') work = True with Board() as board: while work: board.led.state = Led.PULSE_SLOW lang = vision_recog.lang vision_recog.show_say('talk_start_button', True) hints = vision_recog.get_hints() hints_str = "\n".join(hints) vision_recog.show_say('command_list') logging.info(hints_str) vision_recog.show_say('waiting_button') client_cloudSpeech = CloudSpeechClient() board.button.wait_for_press() # If you use the sound of button pushed subprocess.run(['aplay', './button_sound.wav']) vision_recog.show_say('waiting_command') text = client_cloudSpeech.recognize(language_code=lang, hint_phrases=hints) if text is None: vision_recog.show_say('talk_sorry', True) else: results = None text = text.lower() vision_recog.show_say('your_command') logging.info(text) if text in hints: if text in words_dict[lang]['finish_list']: vision_recog.show_say('talk_finish', True) work = False else: results = vision_recog.recognition_process(text) vision_recog.say(results) else: vision_recog.show_say('talk_again', True)
def main(): logging.basicConfig(level=logging.DEBUG) signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0)) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) parser.add_argument('--volume', type=volume, default=100) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) client = CloudSpeechClient() with Board() as board: assistant = AssistantServiceClientWithLed(board=board,volume_percentage=args.volume, language_code=args.language) text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Good morning Lauren, did you sleep well??') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('I\'m glad that you\'re rested. Have you had breakfast yet?') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Your food shop isn\'t being delivered until tomorrow. We could either pop to Tesco or go to that nice deli on North End Road.') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Good idea! Why not invite Alisa round for some mezze and wine? You guys haven\'t caught up in a while.') text = client.recognize(language_code=args.language, hint_phrases=hints) aiy.voice.tts.say('Sure. Do you want to call her now to see if she\'s free?') text = client.recognize(language_code=args.language, hint_phrases=hints) while True: hs=False text = client.recognize(language_code=args.language, hint_phrases=hints) if 'are you here' in text: aiy.voice.tts.say('yes I am here') hs=True continue elif 'power off' in text: aiy.voice.tts.say('goodbye for now') break elif hs==False: logging.info('Conversation normal----!') assistant.conversation() continue
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: #board.led.state = Led.ON with Leds() as leds: while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'turn on the light' in text: board.led.state = Led.ON elif 'turn off the light' in text: board.led.state = Led.OFF elif 'blink the light' in text: board.led.state = Led.BLINK elif 'goodbye' in text: break elif 'happy' in text: leds.pattern = Pattern.blink(50) color = (255, 255, 0) leds.update(Leds.rgb_pattern(color)) audio.play_wav('laugh.wav') elif 'creep' in text: leds.pattern = Pattern.breathe(1000) color = (102, 140, 255) leds.update(Leds.rgb_on(color)) elif 'cheer' in text: leds.pattern = Pattern.blink(5) color = (230, 0, 115) leds.update(Leds.rgb_on(color)) audio.play_wav('people-cheering.wav')
def main(): recognizer = CloudSpeechClient.recognize(self) recognizer.expect_phrase('The number is 1.') recognizer.expect_phrase('The number is 2.') recognizer.expect_phrase('The number is 3.') recognizer.expect_phrase('What is the number?') aiy.audio.get_recorder().start() while True: print('Press the button and speak') button.wait_for_press() print('Listening...') text = recognizer.recognize() if not text: print('Sorry, I did not hear you.') else: print('You said "', text, '"') if 'The number is 1.' in text: number = 1 elif 'The number is 2.' in text: number = 2 elif 'The number is 3.' in text: number = 3 elif 'What is the number?' in text: print(number) break
def main(): logging.basicConfig(level=logging.DEBUG) signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0)) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) parser.add_argument('--volume', type=volume, default=100) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) client = CloudSpeechClient() with Board() as board: name = 'Mary' aiy.voice.tts.say('Hi there' + str(name) + 'nice to meet you') time.sleep(0.5) aiy.voice.tts.say( 'sorry if i did not pronounce that correctly, I am always learning' ) time.sleep(0.5) aiy.voice.tts.say( 'Could you tell me your personality type, this is so I get to know you better. just say the four letters' ) text = client.recognize(language_code=args.language, hint_phrases=hints) psn = input() aiy.voice.tts.say('Oh thank you so you are type' + str(psn[0])) time.sleep(0.5) aiy.voice.tts.say(str(psn[1])) time.sleep(0.5) aiy.voice.tts.say(str(psn[2])) time.sleep(0.5) aiy.voice.tts.say(str(psn[3])) time.sleep(0.5) aiy.voice.tts.say( 'Wait a second, I need to configure my settings for you') time.sleep(0.5) aiy.voice.tts.say('Let us talk. So how have you been lately?') text = client.recognize(language_code=args.language, hint_phrases=hints) convo_finished = False while convo_finished != True: amica = input() aiy.voice.tts.say(str(amica))
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'turn on the light' in text: board.led.state = Led.ON elif 'turn off the light' in text: board.led.state = Led.OFF elif 'blink the light' in text: board.led.state = Led.BLINK elif 'linear' in text: # Remove "repeat after me" from the text to be repeated linear_velocity = text.replace('linear', '', 1) #aiy.voice.tts.say(to_repeat) print('Linear Velocity: ', float(linear_velocity)) elif 'angular' in text: # Remove "repeat after me" from the text to be repeated angular_velocity = text.replace('angular', '', 1) #aiy.voice.tts.say(to_repeat) print('Angular Velocity: ', float(angular_velocity)) elif 'goodbye' in text: break
def __init__(self,args): # get commands # intitalise commands self.commands = load(open(path+'/'+'commands.yaml').read(), Loader=Loader) #initialise voice server self.args = args logging.basicConfig(level=logging.DEBUG) logging.info('Initializing for language %s...', args.language) self.hints = tuple(self.commands.keys()) self.client = CloudSpeechClient() # initialise transmitted commands self.v = 0.0 self.w = 0.0 #initialise lock self._lock=threading.RLock() pass
def startOrder(): d = datetime.datetime.now() if(d.month<10): if(d.day<10): d = str(d.year)+"0"+str(d.month)+"0"+str(d.day) else: d = str(d.year)+"0"+str(d.month)+str(d.day) else: if(d.day<10): d = str(d.year)+str(d.month)+"0"+str(d.day) else: d = str(d.year)+str(d.month)+str(d.day) pid = mcs_api.get_mcs_id() pid = pid.split('*') #print(pid) d = "UploadFiles/"+d+"-"+pid[1] logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: #if hints: # logging.info('Say something, e.g. %s.' % ', '.join(hints)) #else: # logging.info('Say something.') text = client.recognize(language_code='zh-TW', hint_phrases=hints) files.to_text(d, text) if text is None: #logging.info('You said nothing.') if mcs_api.get_mcs_start()=='off': break; elif '我想搜索文件' in text: say("start listening") return 'yes'; break;
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Vision & Speech Demo') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: board.led.state = Led.PULSE_QUICK if hints: logging.info('Push the button & show me something, e.g. %s.' % ', '.join(hints)) else: logging.info('Push the button & show me something.') text = client.recognize(language_code=args.language, hint_phrases=hints) board.button.wait_for_press() if text is None: logging.info('Sorry, what was that?') continue logging.info('You said: "%s"' % text) text = text.lower() if 'what is that' in text: output = whatisthat.takeAndProcessImage('label') elif 'what logo is that' in text: output = whatisthat.takeAndProcessImage('logo') elif 'what does that say' in text: output = whatisthat.takeAndProcessImage('text') elif 'goodbye' in text: break # If we got a result then both print and speak it. if output is not None: print(output) aiy.voice.tts(output)
def run(self): global l_audio global q_read client = CloudSpeechClient() while True: l_audio.acquire() lightHandler.pre_listen() read = client.recognize(language_code="it_IT", hint_phrases=hints) l_audio.release() if self.stopped: return if read is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % read) read = read.lower() q_read.put(read) while not gbl.listen: time.sleep(0.1)
def main(): with Board() as board: hints = get_hints(args.language) client = CloudSpeechClient() while True: print('Press button to send commands to the robot') board.wait_for_press() text = client.recognize(language_code=args.language, hint_phrases=hints) if text: print("You said : " + text) if text == "Qual è l'evento migliore del mondo?": text = """Laic et om è l'evento che ti farà sentire a casa! All'evento i partecipanti riceveranno dei Vois chit (proprio come me!) e dovranno sviluppare nuove schill che rendano Google Assistant il miglior coinquilino che ci sia. Lo scopo è far sentire a casa anche gli studenti fuorisede. L'evento si terrà sabato 30 marzo e domenica 31. Nel costo del biglietto sono inclusi l'ingresso e parecchi gadget. Il pranzo, la merenda, la cena, la colazione, caffe e redbull sono gratuiti per tutti i partecipanti. Cosa aspettate? Sentitevi Like at Home!""" aiy.voice.tts.say(text) else: text = "ok google qual e l'evento migliore del mondo?" aiy.voice.tts.say(text)
def main(): logging.basicConfig(level=logging.INFO) signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0)) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) parser.add_argument('--volume', type=volume, default=100) args = parser.parse_args() client = CloudSpeechClient() with Board() as board: assistant = AssistantServiceClientWithLed(board=board, volume_percentage=args.volume, language_code=args.language) while : logging.info('Press button to start conversation...') board.button.wait_for_release() logging.info('Conversation started!') # assistant.conversation() text = client.recognize(language_code=args.language) if text: ascii_print(text, board)
def main(): pygame.mixer.init() logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() # -------------------------- if 'licht' in text: synthesize_text('ok') board.led.state = Led.ON elif 'mach es wieder aus' in text: synthesize_text('Alles klar!') board.led.state = Led.OFF elif 'voice user interface' in text: board.led.state = Led.BLINK_3 elif 'hast du das gespeichert' in text: synthesize_text('selbstverständlich!') board.led.state = Led.OFF
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'turn on the light' in text: board.led.state = Led.ON elif 'turn off the light' in text: board.led.state = Led.OFF elif 'blink the light' in text: board.led.state = Led.BLINK # Our new command: if 'repeat after me' in text: # Remove "repeat after me" from the text to be repeated to_repeat = text.replace('repeat after me', '', 1) aiy.voice.tts.say(to_repeat) if 'tell me a joke' in text: aiy.voice.tts.say('I was gonna tell a time travelling joke but you guys did not like it') elif 'goodbye' in text: break
class MyDaemonSTT: def __init__(self): # client variable for each instance of MyDaemonSTT self.client = CloudSpeechClient() # set the langauge code to the local language code self.language_code = locale_language() # create a set of hint phrases to bias the recognition self.hints = get_hints("en-GB") self.text = "" def capture_utterance(self): # recognize from the mic and store results in self.text self.text = self.client.recognize(self.language_code, self.hints) return self.text
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) client = CloudSpeechClient() with Board() as board: aiy.voice.tts.say( readFile("pixyResponse.txt"), 'en-GB', 10, 180, 90, 'default') #text,language,volume,pitch,speed,device='default'
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() with Board() as board: while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'turn on the light' in text: tts.say('Turning on LED') board.led.state = Led.ON elif 'turn off the light' in text: tts.say('Turning off LED') board.led.state = Led.OFF elif 'blink the light' in text: tts.say('Blinking LED') board.led.state = Led.BLINK elif 'goodbye' in text: tts.say('See you real soon.') break