def myservice(): led.set_state(led_state['listening']) stt_text = gkit.getVoice2Text() led.set_state(led_state['playing']) print(stt_text) if stt_text != '': gkit.tts_play(stt_text) led.set_state(led_state['ready'])
def sample(): gkit.kws_start() gkit.kws_setkeyword('기가지니') while True: print('========') if gkit.kws_detect() == 1: stt_text = gkit.getVoice2Text() print(stt_text) if stt_text != '': gkit.tts_play(stt_text)
def login_by_password(): global cnt_attempt cnt_attempt += 1 # do you want to enter password gkit.tts_play('암호를 입력 하시겠습니까') text = gkit.getVoice2Text() print(text) # yes if (cnt_attempt % 3 != 0): # if (text.find('예') >= 0 or text.find('yes') >= 0): # input plz gkit.tts_play('환영') for no_try in range(TRY_LIMIT): password = gkit.getVoice2Text() print(password) if (password.find(PASSWORD) >= 0 and len(password) <= 5 * len(PASSWORD)): # welcome # gkit.tts_play('환영') return 1 elif no_try < TRY_LIMIT - 1: # please try again gkit.tts_play('다시 시도해주세요.') else: # see you again gkit.tts_play('또 보자') return 0 return -1
def sample(): point = 0 gkit.set_clientkey(CLIENT_ID, CLIENT_KEY, CLIENT_SECRET) gkit.kws_start() gkit.kws_setkeyword('기가지니') while True: print('========') point = point + 1 if gkit.kws_detect() == 200: stt_text = gkit.getVoice2Text() if point % 2 == 1: GPIO.output(5, GPIO.HIGH) # out if point % 2 == 0: GPIO.output(5, GPIO.LOW) # out print(stt_text) if stt_text != '': gkit.tts_play(stt_text) else: GPIO.cleanup()
def face_detect(): camera = picamera.PiCamera() camera.resolution = (200, 150) camera.start_preview() start = time.time() detected = False TEMP_PATH = 'tmp.jpg' while True: if os.path.isfile(UNKNOWN_PATH): os.remove(UNKNOWN_PATH) camera.capture(TEMP_PATH) result = auth.authenticate(TEMP_PATH) if result[0] != 1: shutil.copy(TEMP_PATH, UNKNOWN_PATH) if result[0] == 0: print('Welcome %s' % result[1]) detected = True break else: print('Sad: %s' % result[1]) if time.time() - start > 5: print('Your time ran out') break camera.stop_preview() camera.close() if not detected: #login val = login_by_password() if (val == 1): detected = True # do not want to input password elif (val == 0): # you shall not pass gkit.tts_play('너는지나 가지 않아야한다.') return detected detect_person(detected) if detected: play_file('../data/sample_sound.wav') # Play a welcome sound gkit.tts_play('환영') print('Door open') return True # you have tried ur best. good luck on next time gkit.tts_play('다음 번에 최선을 다해 행운을 빕니다.') return False
def onButtonHandler(): print("Button was pressed") stt_text = gkit.getVoice2Text() print(stt_text) if stt_text != '': gkit.tts_play(stt_text)