Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite locale strings to IETF standard and check for model existence #526

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion main/states/recognizing_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ def __recognize_audio(self, recognizer, audio):
self.components.config['default_stt'] = 'google'
return recognizer.recognize_google(audio, language=susi_config["language"])
else:
return recognizer.recognize_sphinx(audio, language=susi_config["language"])
if susi_config["language"][0:2] == 'it' and 'it-IT' in self.components.pocketsphinx_supported_langs:
sphinxlang = 'it-IT'
elif susi_config["language"][0:2] == 'zh' and 'zh-CN' in self.components.pocketsphinx_supported_langs:
sphinxlang = 'zh-CN'
else:
# fall back to English
sphinxlang = 'en-US'
return recognizer.recognize_sphinx(audio, sphinxlang)

elif self.components.config['default_stt'] == 'bing':
api_key = self.components.config['bing_speech_api_key']
Expand Down
6 changes: 5 additions & 1 deletion main/states/susi_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import requests
import json_config

import os
import speech_recognition
from speech_recognition import Recognizer, Microphone
from requests.exceptions import ConnectionError

Expand Down Expand Up @@ -91,6 +92,9 @@ def __init__(self, renderer=None):
logger.warning("Susi has the wake button disabled")
self.wake_button = None

# determine PocketSphinx supported languages
self.pocketsphinx_supported_langs = os.listdir(os.path.dirname(speech_recognition.__file__) + '/pocketsphinx-data')

def server_checker(self):
response_one = None
test_params = {
Expand Down