|
@@ -19,6 +19,8 @@ class Cmusphinx(SpeechRecognition):
|
|
|
self.main_controller_callback = callback
|
|
|
self.language = kwargs.get('language', "en-US")
|
|
|
self.keyword_entries = kwargs.get('keyword_entries', None)
|
|
|
+ # ge the grammar file if exist
|
|
|
+ self.grammar_file = kwargs.get('grammar_file', None)
|
|
|
|
|
|
# start listening in the background
|
|
|
self.set_callback(self.sphinx_callback)
|
|
@@ -30,8 +32,10 @@ class Cmusphinx(SpeechRecognition):
|
|
|
called from the background thread
|
|
|
"""
|
|
|
try:
|
|
|
- captured_audio = recognizer.recognize_sphinx(audio, language=self.language,
|
|
|
- keyword_entries=self.keyword_entries)
|
|
|
+ captured_audio = recognizer.recognize_sphinx(audio,
|
|
|
+ language=self.language,
|
|
|
+ keyword_entries=self.keyword_entries,
|
|
|
+ grammar=self.grammar_file)
|
|
|
Utils.print_success("Sphinx Speech Recognition thinks you said %s" % captured_audio)
|
|
|
self._analyse_audio(captured_audio)
|
|
|
|