def step_impl(context): route = directions.get_directions(context.route_from, context.route_from, context.route_mode) assert route is not None context.route = route dur = directions.route_duration(route) ya_speech.synthesize('Маршрут займет ' + str(dur) + ' минут', context.va)
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 step_impl(context): assert context.name_active is not None assert context.va_task == 'save' assert context.task_status == 'approved' res = locations.add_location(context.name_active, context.location) if res != 'ok': context.task_status = 'rejected' ya_speech.synthesize( 'Место ' + context.name_active + ' уже существует!', context.va)
def approve_location(context): if context.va_task == 'save': if context.location is not None: address = maps_functions.get_address(context.location) if address is not None: ya_speech.synthesize(address, context.va) else: ya_speech.synthesize('Не могу определить адрес точки', context.va) if context.task_status == 'set': context.task_status = 'waits_approve'
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 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_user(context): if context.user_last_command is None: ya_speech.synthesize('Ошибка распознавания', context.va)
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_user(context): if context.user_last_command == "привет борис": ya_speech.synthesize('Привет!', context.va)
def step_impl(context): assert context.name_active_loc != 'not found' ya_speech.synthesize('Вы хотите изменить имя или адрес?', context.va) pass
def step_impl(context): ya_speech.synthesize('Задайте новое имя', context.va) pass
def get_location_fail(context): if context.user_last_command == "сохранить текущее местоположение": if context.location is None: ya_speech.synthesize('Не могу определить местоположение', context.va)
def step_impl(context): ya_speech.synthesize('Все верно?', context.va) pass
def delete_location_confirm(context): ya_speech.synthesize('Удалить?', context.va) pass
def delete_location_not_found(context): assert context.name_active_loc == 'not found' ya_speech.synthesize('Место ' + context.name_active + ' не найдено', context.va)
def location_name(context): ya_speech.synthesize('Задай имя', context.va) assert ya_speech.recognize(context.va) == "задай имя"
def step_impl(context): ya_speech.synthesize('Задайте новое местоположение', context.va) pass
def approve_location(context): assert context.task_status == 'waits_approve' ya_speech.synthesize('Продолжить?', context.va)
def save_confirm(context): ya_speech.synthesize('задача отменена', context.va) pass
def hello_user(context): ya_speech.synthesize('Привет!', context.va) assert ya_speech.recognize(context.va) == "привет"
def step_impl(context): assert context.task_status == "done" ya_speech.synthesize('Готово!', context.va)
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 save_confirm(context): assert context.task_status == "rejected" ya_speech.synthesize('Задача отменена', context.va)
def location_name(context): if context.va_task == 'save' and context.task_status == 'approved': ya_speech.synthesize('Задай имя', context.va)
def step_impl(context): ya_speech.synthesize('Начать маршрут', context.va)
def step_impl(context): assert context.name_active_loc != 'not found' address = maps_functions.get_address(context.name_active_loc) ya_speech.synthesize(context.name_active + ' ' + address, context.va)