소스 검색

Merge pull request #259 from Ultchad/sphinx_language

Add language option to CMUSphinx
Nicolas Marcq 8 년 전
부모
커밋
be2371cb07
2개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 1
      kalliope/stt/cmusphinx/README.md
  2. 2 1
      kalliope/stt/cmusphinx/cmusphinx.py

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

@@ -18,7 +18,8 @@ sudo pip install pocketsphinx
 Then, declare it as usual in your settings
 ```YAML
 default_speech_to_text: "cmusphinx"
-# no parameters for this one
+
 speech_to_text:  
   - cmusphinx
+    language: "en-US" #  [Installing other languages](https://github.com/Uberi/speech_recognition/blob/master/reference/pocketsphinx.rst#installing-other-languages)
 ```

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

@@ -17,6 +17,7 @@ class Cmusphinx(SpeechRecognition):
 
         # callback function to call after the translation speech/tex
         self.main_controller_callback = callback
+        self.language = kwargs.get('language', "en-US")
 
         # start listening in the background
         self.set_callback(self.sphinx_callback)
@@ -28,7 +29,7 @@ class Cmusphinx(SpeechRecognition):
         called from the background thread
         """
         try:
-            captured_audio = recognizer.recognize_sphinx(audio)
+            captured_audio = recognizer.recognize_sphinx(audio, language=self.language)
             Utils.print_success("Sphinx Speech Recognition thinks you said %s" % captured_audio)
             self._analyse_audio(captured_audio)