def location_name(context, name): if name != 'nothing': ya_speech.synthesize(name, context.user) context.name_active = ya_speech.recognize(context.user) assert context.name_active is not None else: context.name_active = ya_speech.recognize('audio_files/empty_file.wav') assert context.name_active is None if context.name_active is not None: res = locations.add_location(context.name_active, context.location) context.save_result = res
def approve_location(context): address = maps_functions.get_address(context.location) assert address is not None ya_speech.synthesize(address, context.va) address_clean = additional_funcs.clear_address(address) print(ya_speech.recognize(context.va)) print(address_clean) # assert ya_speech.recognize(context.va) == address_clean # TODO тут косяк с сокращениями и вообще адресом ya_speech.synthesize('Подтверждаете?', context.va) assert ya_speech.recognize(context.va) == "подтверждаете"
def location_name_new(context, name): if name != 'nothing': assert context.name_active is not None context.name_new = name.lower() else: context.name_new = ya_speech.recognize('audio_files/empty_file.wav') assert context.name_new is None
def delete_location(context): res = locations.remove_location(context.name_active) assert res == "ok" assert locations.get_by_name(context.name_active) == 'not found' context.name_active = None ya_speech.synthesize('Удалено', context.va) assert ya_speech.recognize(context.va) == "удалено"
def confirm_location_saved(context): assert context.save_result == "ok" ya_speech.synthesize('Место ' + context.name_active + ' сохранено!', context.va) assert ya_speech.recognize( context.va) == "место " + context.name_active + " сохранено" context.name_active = None
def get_location(context): context.user_last_command = ya_speech.recognize( "audio_files/save_location.wav") assert context.user_last_command == "сохранить текущее местоположение" if context.va_task is None: context.va_task = 'save' context.task_status = 'set' context.location = maps_functions.get_current_geo()
def step_impl(context): if context.change_property == 'name': address = maps_functions.get_address(context.name_active_loc) assert address is not None name = context.name_new elif context.change_property == 'address': address = context.address_new name = context.name_active else: assert False ya_speech.synthesize(address, context.va) # address_clean = additional_funcs.clear_address(address) # assert ya_speech.recognize(context.va) == address_clean # TODO тут косяк с сокращениями и вообще адресом ya_speech.synthesize('Подтверждаете?', context.va) assert ya_speech.recognize(context.va) == "подтверждаете"
def confirm_location_upd(context): if context.change_property == 'name': loc = context.name_active_loc assert loc is not None name_new = context.name_new name_old = context.name_active elif context.change_property == 'address': loc = maps_functions.get_geo(context.address_new) assert loc is not None name_new = context.name_active name_old = name_new else: assert False res = locations.remove_location(name_old) assert res == "ok" res = locations.add_location(name_new, loc) assert res == "ok" context.name_active = None ya_speech.synthesize('Место изменено', context.va) assert ya_speech.recognize(context.va) == "место изменено"
def hello_boris(context): # recognize command from mic # hello = ya_speech.recognize(context.user) context.user_last_command = ya_speech.recognize( "audio_files/hello_boris.pcm") assert context.user_last_command == 'привет борис'
def save_confirm(context): assert ya_speech.recognize("audio_files/net.wav") == 'нет'
def location_name(context): ya_speech.synthesize('Задай имя', context.va) assert ya_speech.recognize(context.va) == "задай имя"
def hello_boris(context): # hello = ya_speech.recognize(context.user) hello = ya_speech.recognize("audio_files/hello_boris.pcm") assert hello == 'привет борис'
def get_location_fail(context): context.location = None assert context.location is None ya_speech.synthesize('Не могу определить местоположение', context.va) assert ya_speech.recognize( context.va) == "не могу определить местоположение"
def get_location(context): save_loc = ya_speech.recognize("audio_files/save_location.wav") assert save_loc == "сохранить текущее местоположение" context.location = maps_functions.get_current_geo() assert context.location is not None
def confirm_location_saved(context): assert context.save_result == "already exists" ya_speech.synthesize('Место ' + context.name_active + ' уже существует!', context.va) assert ya_speech.recognize( context.va) == "место " + context.name_active + " уже существует"
def hello_boris(context): context.user_last_command = ya_speech.recognize( 'audio_files/empty_file.wav') assert context.user_last_command is None
def step_impl(context): assert ya_speech.recognize("audio_files/net.wav") == 'нет' if context.va_task is not None and context.task_status == 'waits_approve': context.task_status = 'rejected'
def hello_user(context): ya_speech.synthesize('Привет!', context.va) assert ya_speech.recognize(context.va) == "привет"