'Initiates the pocketsphinx instance.
Arguments:
vocabulary -- a PocketsphinxVocabulary instance
hmm_dir -- the path of the Hidden Markov Model (HMM)'

def __init__(self, vocabulary, hmm_dir=('/usr/local/share/' + 'pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k')):

    self._logger = logging.getLogger(__name__)
    try:
        import pocketsphinx as ps
    except:
        import pocketsphinx as ps
    with tempfile.NamedTemporaryFile(prefix='psdecoder_', suffix='.log', delete=False) as f:
        self._logfile = f.name
    self._logger.debug(('Initializing    PocketSphinx    Decoder    with    hmm_dir    ' + "'%s'"), hmm_dir)
    if (not os.path.exists(hmm_dir)):
        msg = (("hmm_dir    '%s'    does    not    exist!    Please    make    sure    that    you    " + 'have    set    the    correct    hmm_dir    in    your    profile.') % hmm_dir)
        self._logger.error(msg)
        raise RuntimeError(msg)
    missing_hmm_files = []
    for fname in ('mdef', 'feat.params', 'means', 'noisedict', 'transition_matrices', 'variances'):
        if (not os.path.exists(os.path.join(hmm_dir, fname))):
            missing_hmm_files.append(fname)
    mixweights = os.path.exists(os.path.join(hmm_dir, 'mixture_weights'))
    sendump = os.path.exists(os.path.join(hmm_dir, 'sendump'))
    if ((not mixweights) and (not sendump)):
        missing_hmm_files.append('mixture_weights    or    sendump')
    if missing_hmm_files:
        self._logger.warning((("hmm_dir    '%s'    is    missing    files:    %s.    Please    " + 'make    sure    that    you    have    set    the    correct    ') + 'hmm_dir    in    your    profile.'), hmm_dir, ',    '.join(missing_hmm_files))
    self._decoder = ps.Decoder(hmm=hmm_dir, logfn=self._logfile, **vocabulary.decoder_kwargs)
