summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2015-01-11 13:08:56 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2015-01-11 13:08:56 +0100
commitf2dadd12c74a72b18c60d29d8aaa4b863527cba1 (patch)
treed0c0222dca0b1c7da65d75833f4ba29648974ace
parent2eefdad377ec41442b5387efeec83a6b1e411a98 (diff)
downloadjasper-client-f2dadd12c74a72b18c60d29d8aaa4b863527cba1.tar.gz
jasper-client-f2dadd12c74a72b18c60d29d8aaa4b863527cba1.zip
Better error-checking/logging during Pocketsphinx STT engine init
-rw-r--r--client/stt.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/client/stt.py b/client/stt.py
index 4298cd2..95ed487 100644
--- a/client/stt.py
+++ b/client/stt.py
@@ -91,6 +91,35 @@ class PocketSphinxSTT(AbstractSTTEngine):
suffix='.log', delete=False) as f:
self._logfile = f.name
+ self._logger.debug("Initializing PocketSphinx Decoder with hmm_dir " +
+ "'%s'", hmm_dir)
+
+ # Perform some checks on the hmm_dir so that we can display more
+ # meaningful error messages if neccessary
+ 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)
+ # Lets check if all required files are there. Refer to:
+ # http://cmusphinx.sourceforge.net/wiki/acousticmodelformat
+ # for details
+ 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:
+ # We only need mixture_weights OR 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)