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

Commit

Permalink
Fallback to default STT if loading fails
Browse files Browse the repository at this point in the history
If a STT backend fails to load log the exception and fallback to the
MycroftSTT.
  • Loading branch information
forslund committed Oct 26, 2019
1 parent a3e35d7 commit 741cc1c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions mycroft/stt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,17 @@ class STTFactory:

@staticmethod
def create():
config = Configuration.get().get("stt", {})
module = config.get("module", "mycroft")
clazz = STTFactory.CLASSES.get(module)
return clazz()
try:
config = Configuration.get().get("stt", {})
module = config.get("module", "mycroft")
clazz = STTFactory.CLASSES.get(module)
return clazz()
except Exception as e:
# The STT backend failed to start. Report it and fall back to
# default.
LOG.exception('The selected STT backend could not be loaded, '
'falling back to default...')
if module != 'mycroft':
return MycroftSTT()
else:
raise

0 comments on commit 741cc1c

Please sign in to comment.