Skip to content

Commit

Permalink
Fix autodoc for the Pocket Sphinx engine module
Browse files Browse the repository at this point in the history
This should make the Engine API section in the docs build
correctly.
  • Loading branch information
drmfinlay committed Oct 11, 2018
1 parent d4da684 commit 2c28471
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions dragonfly/engines/backend_sphinx/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,25 @@

from threading import Timer, RLock, current_thread

from jsgf import GrammarError, RootGrammar, PublicRule, Literal
from pyaudio import PyAudio

from dragonfly import Grammar, Window
from dragonfly.engines.backend_sphinx import is_engine_available
from dragonfly.engines.backend_sphinx.grammar_wrapper import GrammarWrapper,\
ProcessingState
from dragonfly.engines.backend_sphinx.training import TrainingDataWriter
from dragonfly2jsgf import Translator

from .compiler import SphinxJSGFCompiler
from .dictation import SphinxDictationContainer
from .recobs import SphinxRecObsManager
from ..base import EngineBase, EngineError, MimicFailure

try:
from sphinxwrapper import *
from jsgf import GrammarError, RootGrammar, PublicRule, Literal
from pyaudio import PyAudio

from dragonfly2jsgf import Translator
from .compiler import SphinxJSGFCompiler
from .grammar_wrapper import GrammarWrapper, ProcessingState
except ImportError:
# This is checked again in is_engine_available(). It's done here purely for
# readability:
# e.g. using PocketSphinx instead of sphinxwrapper.PocketSphinx
# Import a few things here optionally for readability (the engine won't start
# without them) and so that autodoc can import this module without them.
pass


Expand All @@ -76,9 +74,12 @@ def __init__(self):

try:
import sphinxwrapper
import jsgf
import pyaudio
except ImportError:
self._log.error("%s: failed to import sphinxwrapper module." % self)
raise EngineError("Failed to import the sphinxwrapper module.")
self._log.error("%s: Failed to import jsgf, pyaudio and/or "
"sphinxwrapper. Are they installed?" % self)
raise EngineError("Failed to import Pocket Sphinx engine dependencies.")

# Import and set the default configuration module. This can be changed later
# using the config property.
Expand Down

0 comments on commit 2c28471

Please sign in to comment.