Example #1
0
def listen_wake_word():
    global snowboy

    snowboy = snowboydecoder.HotwordDetector(
        "snowboy/examples/Python/resources/models/snowboy.umdl",
        sensitivity=0.5)
    print("starting thread snowboy")
    snowboy.start(detected_callback=wakeword_detected, sleep_time=0.25)
Example #2
0
def main(sensitivty_level):
    header = "*******TEST WITH {} SENSITIVITY*******\n".format(
        sensitivty_level)
    record_result(header)
    print(header)
    start_info = "Test starts at {}\n".format(datetime.datetime.now().time())
    print(start_info)
    record_result(start_info)
    global detector
    detector = snowboydecoder_arecord.HotwordDetector(
        "snowboy.pmdl", sensitivity=sensitivty_level)
    detect_hotword()
    end_info = "Test finishes at {}\n".format(datetime.datetime.now().time())
    print(end_info)
    record_result(end_info)
    false_detections_info = "There were {} false detections\n".format(
        false_detections)
    print(false_detections_info)
    record_result(false_detections_info)
Example #3
0
    interrupted = True


def interrupt_callback():
    global interrupted
    return interrupted


def myCallback():
    print("OH my GOD!!!")


if __name__ == "__main__":

    model = "heyneo.pmdl"

    # capture SIGINT signal, e.g., Ctrl+C
    signal.signal(signal.SIGINT, signal_handler)

    detector = snowboydecoder_arecord.HotwordDetector(model, sensitivity=0.5)
    print('Listening... Press Ctrl+C to exit')

    # main loop
    detector.start(
        detected_callback=
        myCallback,  #detected_callback=snowboydecoder_arecord.play_audio_file,
        interrupt_check=interrupt_callback,
        sleep_time=0.03)

    detector.terminate()

# return the hotword for current security setting
def get_hotword_set():
    # connection to database which stores all security information
    with sqlite3.connect(security_db) as connection:
        cursor = connection.cursor()
        cursor.execute("SELECT * FROM security")
        # return the universal or personal model depending on settings
        hotword_file = cursor.fetchall()[0][1]
        print(hotword_file)
        return "/home/pi/2019-ca400-randlea2/src/" + hotword_file


# get current hotword set from security table
detector = snowboydecoder_arecord.HotwordDetector(get_hotword_set(),
                                                  sensitivity=0.45)


def detected():
    #  hotword has been detected, start recording command keywords
    detector.terminate()
    subprocess.call(
        ["/home/pi/2019-ca400-randlea2/src/suspend_sound_services.sh"])
    snowboydecoder_arecord.play_audio_file()
    command_recogniser.query_user()
    print("hotword detected")


def detect_hotword():
    global detector
    signal.signal(signal.SIGINT, signal_handler)
Example #5
0
def signal_handler(signal, frame):
    global interrupted
    interrupted = True


def interrupt_callback():
    global interrupted
    return interrupted


if len(sys.argv) == 1:
    logger.info('Error: need to specify ini file')
    logger.info('Usage: python {0} [your ini file]'.format(__file__))
    sys.exit(-1)

# capture SIGINT signal, e.g., Ctrl+C
signal.signal(signal.SIGINT, signal_handler)

detector = snowboydecoder_arecord.HotwordDetector(config.get(
    'snowboy', 'model'),
                                                  sensitivity=[0.8, 0.8],
                                                  audio_gain=2.0)
logger.info('Listening... Press Ctrl+C to exit')

# main loop
detector.start(detected_callback=detectedCallback,
               interrupt_check=interrupt_callback,
               sleep_time=0.03)

detector.terminate()