def detect(): with MicrophoneStream(RATE, CHUNK) as stream: audio_generator = stream.generator() for content in audio_generator: now = datetime.now() if (now.hour == int(drug_h) and now.minute == int(drug_m) and now.second == 0): drug_flag = 1 output_file = "drug_text.wav" getText2VoiceStream("약 먹을 시간입니다.", output_file) play_file(output_file) elif (now.hour == int(rice_h) and now.minute == int(rice_m) and now.second == 0): rice_flag = 1 output_file = "rice_text.wav" getText2VoiceStream("식사 하실 시간입니다.", output_file) play_file(output_file) rc = ktkws.detect(content) rms = audioop.rms(content, 2) #print('audio rms = %d' % (rms)) if (rc == 1): play_file("../data/sample_sound.wav") return 200
def detect(): with MS.MicrophoneStream(RATE, CHUNK) as stream: audio_generator = stream.generator() for content in audio_generator: rc = ktkws.detect(content) rms = audioop.rms(content,2) #print('audio rms = %d' % (rms)) if (rc == 1): MS.play_file("../data/sample_sound.wav") return 200
def kws_detect(): print('To start, say \"%s\"' % (KWSID[g_kwsid])) with MicrophoneStream(RATE, CHUNK) as stream: audio_generator = stream.generator() for content in audio_generator: rc = ktkws.detect(content) rms = audioop.rms(content, 2) #print('audio rms = %d' % (rms)) if (rc == 1): #play_wav(KWSSOUNDFILE) return rc
def detect(): global btn_status with MS.MicrophoneStream(RATE, CHUNK) as stream: audio_generator = stream.generator() for content in audio_generator: rc = ktkws.detect(content) rms = audioop.rms(content, 2) #print('audio rms = %d' % (rms)) if (btn_status == True): rc = 1 btn_status = False if (rc == 1): # MS.play_file("../data/sample_sound.wav") # 소리시러 return 200
def _detect(self): print('To start, say \"%s\" or press the button. ' 'Press Ctrl+C to quit...' % (KWSID[g_kwsid])) with MicrophoneStream(RATE, CHUNK) as stream: audio_generator = stream.generator() for content in audio_generator: rc = ktkws.detect(content) if (rc == 1): self._player.play_audio() return True if self._button_pressed is True: return True
def btn_detect(): global btn_status with MicrophoneStream(RATE, CHUNK) as stream: audio_generator = stream.generator() for content in audio_generator: GPIO.output(31, GPIO.HIGH) rc = ktkws.detect(content) rms = audioop.rms(content, 2) #print('audio rms = %d' % (rms)) GPIO.output(31, GPIO.LOW) if (btn_status == True): rc = 1 btn_status = False if (rc == 1): GPIO.output(31, GPIO.HIGH) play_file("../data/sample_sound.wav") return 200
def detect(): global button with MicrophoneStream(RATE, CHUNK) as stream: audio_generator = stream.generator() for content in audio_generator: #import binascii #print ("INBYTE: %s" % (binascii.hexlify(bytearray(content)))) GPIO.output(31, GPIO.HIGH) rc = ktkws.detect(content) rms = audioop.rms(content, 2) #print('audio rms = %d' % (rms)) GPIO.output(31, GPIO.LOW) if (button == True): rc = 1 button = False if (rc == 1): GPIO.output(31, GPIO.HIGH) play_file("../data/sample_sound.wav") return 200
def detect_wake_up_word(keyword='기가지니'): if not keyword in KWS_KEYWORDS: return False response_code = ktkws.init("../data/kwsmodel.pack") print('response_code on init = %d' % (response_code)) response_code = ktkws.start() print('response_code on start = %d' % (response_code)) print('\n호출어를 불러보세요~\n') ktkws.set_keyword(KWS_KEYWORDS.index(keyword)) with MS.MicrophoneStream(RATE, CHUNK) as stream: audio_generator = stream.generator() for content in audio_generator: response_code = ktkws.detect(content) if (response_code == 1): MS.play_file("../data/sample_sound.wav") print('\n\n호출어가 정상적으로 인식되었습니다.\n\n') ktkws.stop() return True