def _api_recognition(self, audio): if self.api_option is ApiOption.GOOGLE: return self.recognizer.recognize_google(audio, language=self.language) elif self.api_option is ApiOption.GOOGLE_CLOUD: # Support languages: https://cloud.google.com/speech-to-text/docs/languages return self.recognizer.recognize_google_cloud(audio, credentials_json='', language=self.language) elif self.api_option is ApiOption.SPHINX: # Support languages : https://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/ return self.recognizer.recognize_sphinx(audio, language=self.language) elif self.api_option is ApiOption.WIT: # Support languages : https://wit.ai/faq, login required return self.recognizer.recognize_wit(audio, key='',) elif self.api_option is ApiOption.AZURE_BING: # Support languages : https://docs.microsoft.com/en-us/azure/cognitive-services/bing-web-search/language-support, login required self.recognizer.recognize_bing(audio, key='', language=self.language) elif self.api_option is ApiOption.LEX: # Support languages: ONLY ENG -> https://docs.aws.amazon.com/lex/latest/dg/gl-limits.html return self.recognizer.recognize_lex(audio) elif self.api_option is ApiOption.HOUNDIFY: # Support languages: ONLY ENG, login required return self.recognizer.recognize_houndify(audio, client_id='', client_key='') elif self.api_option is ApiOption.IBM: # Support languages : https://www.ibm.com/watson/services/language-translator/, login required return self.recognizer.recognize_ibm(audio, username='', password='', language=self.language) else: Logger.error("Api recognition option is not defined")
def say(self, text): try: Logger.info("Speaker say : {0}".format(text)) self.engine_speak.say(text) self.engine_speak.runAndWait() except Exception as err: Logger.error("Speaker error : {0}".format(err))
def run_authorization(self): if self.camera.api_runs: self.start_authorization() while not (self.authorization_complete or self.quit_authorization): self.run_api_window() self.stop_authorization() self.network_connection() else: Logger.error("Authorization process will not start when camera is not connected") self.api_window.start_pulse_text("Wymagana \nautoryzacja")
def __init__(self): try: self.engine_speak = pyttsx3.init() self.engine_speak.setProperty('rate', 130) self.engine_speak.setProperty('volume', 1) voices = self.engine_speak.getProperty('voices') self.engine_speak.setProperty('voice', voices[0].id) Logger.debug("Speaker Class initialized correctly") except Exception as err: Logger.error("Speaker initialization error : {0}".format(err))
def __init__(self, parent): Frame.__init__(self, parent, bg=ApiSettings.Background) self.weather_api_token = '' # token from https://darksky.net/dev/ account self.location_info = None self.weather_info = None self.weather_lang = 'pl' self.weather_unit = 'auto' self.weather_icon = None self.degree_frame = Frame(self, bg=ApiSettings.Background) self.degree_frame.pack(side=TOP, anchor=E) self.temperature_label = Label(self.degree_frame, font=(ApiSettings.Font, ApiSettings.HugeTextSize), fg=ApiSettings.Foreground, bg=ApiSettings.Background) self.temperature_label.pack(side=RIGHT, anchor=CENTER) self.icon_label = Label(self.degree_frame, bg=ApiSettings.Background) self.icon_label.pack(side=LEFT, anchor=NW, padx=ApiSettings.PaddingX) self.currently_label = Label(self, font=(ApiSettings.Font, ApiSettings.LargeTextSize - 10), fg=ApiSettings.Foreground, bg=ApiSettings.Background) self.currently_label.pack(side=TOP, anchor=E) self.forecast_label = Label(self, font=(ApiSettings.Font, ApiSettings.MediumTextSize, 'normal', 'italic'), fg=ApiSettings.Foreground, bg=ApiSettings.Background) self.forecast_label.pack(side=TOP, anchor=E) self.location_label = Label(self, font=(ApiSettings.Font, ApiSettings.SmallTextSize), fg=ApiSettings.Foreground, bg=ApiSettings.Background) self.location_label.pack(side=TOP, anchor=E) if self.weather_api_token: Logger.debug("Initialization of Weather class") self.get_weather() else: Logger.error( "Please define api token for https://darksky.net/dev weather data will not be available" )