def kws_start(): if not os.path.isfile(KWSMODELDATA): raise ValueError('File not found: ' + KWSMODELDATA) rc = ktkws.init(KWSMODELDATA) rc = ktkws.start() ktkws.set_keyword(g_kwsid) return rc
def test(): rc = ktkws.init("../data/kwsmodel.pack") print('init rc = %d' % (rc)) rc = ktkws.start() print('start rc = %d' % (rc)) ktkws.set_keyword(KWSID.index('기가지니')) rc = detect() print('detect rc = %d' % (rc)) ktkws.stop()
def btn_test(key_word = '기가지니'): global btn_status rc = ktkws.init("../data/kwsmodel.pack") print ('init rc = %d' % (rc)) rc = ktkws.start() print ('start rc = %d' % (rc)) ktkws.set_keyword(KWSID.index(key_word)) rc = btn_detect() print ('detect rc = %d' % (rc)) ktkws.stop() return rc
def call(key_word): rc = ktkws.init("../data/kwsmodel.pack") # print ('init rc = %d' % (rc)) rc = ktkws.start() # print ('start rc = %d' % (rc)) print("KWS: 호출어 대기중") ktkws.set_keyword(KWSID.index(key_word)) rc = detect() # print ('detect rc = %d' % (rc)) # print ('\n\n호출어가 정상적으로 인식되었습니다.\n\n') ktkws.stop() return rc
def test(key_word = '친구야'): rc = ktkws.init("../data/kwsmodel.pack") print ('init rc = %d' % (rc)) rc = ktkws.start() print ('start rc = %d' % (rc)) print ('\n호출어를 불러보세요~\n') ktkws.set_keyword(KWSID.index(key_word)) rc = detect() print ('detect rc = %d' % (rc)) print ('\n\n호출어가 정상적으로 인식되었습니다.\n\n') ktkws.stop() return rc
def device_awake_btn(key_word='기가지니'): global btn_status rc = ktkws.init("../data/kwsmodel.pack") print('init rc = %d' % (rc)) rc = ktkws.start() print('start rc = %d' % (rc)) print('\n버튼을 눌러보세요~\n') ktkws.set_keyword(KWSID.index(key_word)) rc = btn_detect() print('detect rc = %d' % (rc)) print('\n\n호출어가 정상적으로 인식되었습니다.\n\n') ktkws.stop() return rc
def setKTKws(key_index = 0): key_word = ['기가지니','지니야','친구야','자기야'] rc = ktkws.init("/home/pi/ai-makers-kit/data/kwsmodel.pack") print ('init rc = %d' % (rc)) rc = ktkws.start() print ('start rc = %d' % (rc)) print ('\n호출어를 불러보세요~\n') ktkws.set_keyword(KWSID.index(key_word[key_index])) rc = ktkwsdetect() print ('detect rc = %d' % (rc)) print ('\n\n호출어가 정상적으로 인식되었습니다.\n\n') ktkws.stop() return rc
def btn_test(key_word='기가지니'): global btn_status rc = ktkws.init("../data/kwsmodel.pack") ## print ('init rc = %d' % (rc)) rc = ktkws.start() ## print ('start rc = %d' % (rc)) print('\n----------------------------------------------------------\n') print('버튼을 누르시고 말씀하세요~~\n') ktkws.set_keyword(KWSID.index(key_word)) rc = btn_detect() ## print ('detect rc = %d' % (rc)) ## print ('\n\n호출어가 정상적으로 인식되었습니다.\n\n') ktkws.stop() return rc
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