Ver código fonte

add grammar to cmusphinx STT (#304)

Nicolas Marcq 7 anos atrás
pai
commit
f9de5bc0b4

+ 6 - 0
docker/debian8.dockerfile

@@ -16,6 +16,12 @@ RUN apt-get update && apt-get install -y \
 RUN wget https://bootstrap.pypa.io/get-pip.py
 RUN python get-pip.py
 
+# fix install in container
+RUN pip install --upgrade pip six
+RUN pip install --upgrade pip pyyaml
+RUN pip install --upgrade pip SpeechRecognition
+RUN pip install --upgrade pip Werkzeug
+
 # add a standart user. tests must not be ran as root
 RUN useradd -m -u 1000 tester
 RUN usermod -aG sudo tester

+ 6 - 0
docker/ubuntu_16_04.dockerfile

@@ -16,6 +16,12 @@ RUN apt-get update && apt-get install -y \
 RUN wget https://bootstrap.pypa.io/get-pip.py
 RUN python get-pip.py
 
+# fix install in container
+RUN pip install --upgrade pip six
+RUN pip install --upgrade pip pyyaml
+RUN pip install --upgrade pip SpeechRecognition
+RUN pip install --upgrade pip Werkzeug
+
 # add a standart user. tests must not be ran as root
 RUN useradd -m -u 1000 tester
 RUN usermod -aG sudo tester

+ 3 - 3
install/files/python_requirements.txt

@@ -1,7 +1,7 @@
-six==1.10.0
-SpeechRecognition>=3.5.0
+six>=1.10.0
+SpeechRecognition>=3.7.1
 markupsafe==0.23
-pyaudio==0.2.9
+pyaudio==0.2.11
 pyasn1>=0.1.8
 ansible==2.2.0.0
 #python2-pythondialog==3.4.0

+ 1 - 1
kalliope/_version.py

@@ -1,2 +1,2 @@
 # https://www.python.org/dev/peps/pep-0440/
-version_str = "0.4.4"
+version_str = "0.4.5b"

+ 9 - 1
kalliope/stt/cmusphinx/README.md

@@ -15,7 +15,15 @@ Then install the python lib
 sudo pip install pocketsphinx
 ```
 
-Then, declare it as usual in your settings
+#### Parameters
+
+| parameter       | requiered | type   | default | choices | comment                                                                                                                                                |
+|-----------------|-----------|--------|---------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
+| language        | no        | string | en-US   |         | [Installing other languages](https://github.com/Uberi/speech_recognition/blob/master/reference/pocketsphinx.rst#installing-other-languages)            |
+| keyword_entries | no        | list   |         |         | List of tuples of the form (keyword, sensitivity), where keyword is a phrase, and sensitivity is how sensitive to this phrase the recognizer should be |
+| grammar_file    | no        | string |         |         | FSG or JSGF grammars file path. Note: If `keyword_entries` are passed, `grammar_file` will be ignored                                                  |
+
+Settings example
 ```YAML
 default_speech_to_text: "cmusphinx"
 

+ 6 - 2
kalliope/stt/cmusphinx/cmusphinx.py

@@ -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)
 

+ 3 - 3
setup.py

@@ -66,10 +66,10 @@ setup(
     # required libs
     install_requires=[
         'pyyaml>=3.12',
-        'six==1.10.0',
-        'SpeechRecognition>=3.6.0',
+        'six>=1.10.0',
+        'SpeechRecognition>=3.7.1',
         'markupsafe>=1.0',
-        'pyaudio>=0.2.10',
+        'pyaudio>=0.2.11',
         'pyasn1>=0.2.3',
         'ansible>=2.3',
         py2_prefix + 'pythondialog>=3.4.0',