Пример #1
0
def remove_wake_word(db, wake_word: WakeWord):
    """Remove a wake word and any related sample files from the database

    :param db: Database connection to the Mycroft DB
    :param wake_word: the wake word to delete
    """
    file_repository = WakeWordFileRepository(db)
    wake_word_repository = WakeWordRepository(db)
    if wake_word.id is None:
        wake_word.id = wake_word_repository.get_id(wake_word)
    for wake_word_file in file_repository.get_by_wake_word(wake_word):
        file_repository.remove(wake_word_file)
    wake_word_repository.remove(wake_word)
def check_wake_word_file_table(context):
    """The data representing the audio file is stored correctly on the database."""
    file_repository = WakeWordFileRepository(context.db)
    wake_word = context.wake_words[context.scenario_wake_word]
    wake_word_files = file_repository.get_by_wake_word(wake_word)
    assert_that(len(wake_word_files), equal_to(1))
    wake_word_file = wake_word_files[0]
    assert_that(wake_word_file.name,
                equal_to(context.account.id + ".12345.wav"))
    assert_that(
        wake_word_file.location.directory,
        context.wake_word_dir.joinpath(
            context.scenario_wake_word.replace(" ", "-")),
    )
    assert_that(wake_word_file.location.server, equal_to("127.0.0.1"))
Пример #3
0
def check_wake_word_file_table(context):
    """The data representing the audio file is stored correctly on the database."""
    file_repository = WakeWordFileRepository(context.db)
    context.wake_word_files = file_repository.get_by_wake_word(
        context.expected_wake_word_file.wake_word)
    if context.duplicate_hash:
        expected_file_names = [AUDIO_FILE_NAME, DUPLICATE_FILE_NAME]
        file_count = 2
    else:
        expected_file_names = [AUDIO_FILE_NAME]
        file_count = 1
    assert_that(len(context.wake_word_files), equal_to(file_count))
    for wake_word_file in context.wake_word_files:
        assert_that(wake_word_file.name, is_in(expected_file_names))
        assert_that(
            wake_word_file.location.directory,
            context.wake_word_dir.joinpath(
                context.expected_wake_word_file.wake_word.name.replace(
                    " ", "-")),
        )
        assert_that(wake_word_file.location.server, equal_to("127.0.0.1"))