Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
Add quick defaults for no backend (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
AIIX authored Jan 9, 2023
1 parent 5de17ee commit 86d3297
Show file tree
Hide file tree
Showing 7 changed files with 669 additions and 11 deletions.
70 changes: 68 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SetupState(str, Enum):
WELCOME = "welcome"
SELECTING_LANGUAGE = "language"
SELECTING_BACKEND = "backend"
QUICK_ENGINE_CONFIG = "engine"
SELECTING_STT = "stt"
SELECTING_TTS = "tts"
PAIRING = "pairing"
Expand Down Expand Up @@ -276,6 +277,10 @@ def initialize(self):
self.gui.register_handler("mycroft.device.confirm.tts", self.handle_tts_selected)
self.gui.register_handler("mycroft.device.confirm.language", self.handle_language_selected)
self.gui.register_handler("mycroft.return.select.language", self.handle_language_back_event)
self.gui.register_handler("mycroft.device.quick.setup.back", self.handle_customize_engines_back)
self.gui.register_handler("mycroft.device.quick.setup.customize", self.handle_customize_engines_event)
self.gui.register_handler("mycroft.device.quick.setup.confirm", self.handle_customize_engines_continue)
self.gui.register_handler("mycroft.device.stt.tts.menu.back", self.handle_stt_tts_list_back)

# translations
self.translations["code"] = self.translate_namedvalues("code.spelling")
Expand Down Expand Up @@ -364,7 +369,7 @@ def _init_state(self):
self.first_setup = self.settings.get("first_setup", True)
# uncomment this line for debugging
# will always trigger setup on boot
# self.first_setup = True
self.first_setup = True

if not is_connected():
self.state = SetupState.SELECTING_WIFI
Expand Down Expand Up @@ -432,6 +437,14 @@ def state(self, value):
self._state = value
self.bus.emit(Message("ovos.setup.state", {"state": self._state}))

@property
def preferred_tts_engine(self):
return self.settings.get("preferred_tts_engine")

@property
def preferred_stt_engine(self):
return self.settings.get("preferred_stt_engine")

def handle_get_setup_state(self, message):
self.bus.emit(message.reply("ovos.setup.state",
{"state": self.state}))
Expand Down Expand Up @@ -706,9 +719,62 @@ def handle_no_backend_selected(self, message):
self.setup.change_to_no_backend()
# auto pair
self.pairing.api.activate(self.pairing.uuid, "123ABC")
# continue to STT
if self.pairing_mode != PairingMode.VOICE:
# continue to quick engine configuration
self.handle_quick_engine_configuration()
if self.pairing_mode != PairingMode.GUI:
# continue to stt
self.handle_stt_menu()

### Quick engine configuration
@killable_event(msg="pairing.quick.engine.config.stop",
callback=handle_intent_aborted)
def handle_quick_engine_configuration(self):
self.state = SetupState.QUICK_ENGINE_CONFIG
def_tts_engine = None
def_stt_engine = None

if self.preferred_tts_engine:
def_tts_engine = self.preferred_tts_engine
else:
try:
def_tts_engine = self.config_core["tts"]["module"]
except KeyError:
pass

if self.preferred_stt_engine:
def_stt_engine = self.preferred_stt_engine
else:
try:
def_stt_engine = self.config_core["stt"]["module"]
except KeyError:
pass

if def_tts_engine and def_stt_engine:
self.gui["default_tts_engine"] = def_tts_engine
self.gui["default_stt_engine"] = def_stt_engine
self.handle_display_manager("DefaultsMenu")
self.speak_dialog("quick.defaults.intro", wait=True)
else: # there is no preferred engine set in any of the config files, fallback to stt menu
self.handle_stt_menu()
self.send_stop_signal("pairing.quick.engine.config.stop")

def handle_customize_engines_event(self, message):
self.handle_stt_menu()

def handle_customize_engines_back(self, message):
self.handle_backend_confirmation(selection=BackendType.OFFLINE)
self.send_stop_signal("pairing.quick.engine.config.stop")

def handle_customize_engines_continue(self, message):
self.setup.change_stt({"engine": message.data.get("stt_engine")})
self.setup.change_tts({"engine": message.data.get("tts_engine")})
self.send_stop_signal("pairing.quick.engine.config.stop")
self.end_setup(success=True)

def handle_stt_tts_list_back(self, message):
self.handle_quick_engine_configuration()

### STT selection
@killable_event(msg="pairing.stt.menu.stop",
callback=handle_intent_aborted)
Expand Down
1 change: 1 addition & 0 deletions locale/en-us/dialog/quick.defaults.intro.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The default speech-to-text and text-to-speech engines have been carefully selected to provide the best experience. However, you have the option to choose your own engines if you prefer. If you would like to stick with the default engines, simply continue with the current selection.
Loading

0 comments on commit 86d3297

Please sign in to comment.