def __init__(self): self._logger = logging.getLogger(__name__) # Read config config_file = os.path.abspath(os.path.join(jasperpath.LIB_PATH, 'profile.yml')) self._logger.debug("Trying to read config file: '%s'", config_file) with open(config_file, "r") as f: self.config = yaml.safe_load(f) try: api_key = self.config['keys']['GOOGLE_SPEECH'] except KeyError: api_key = None try: stt_engine_type = self.config['stt_engine'] except KeyError: stt_engine_type = "sphinx" self._logger.warning("stt_engine not specified in profile, defaulting to '%s'", stt_engine_type) # Compile dictionary sentences, dictionary, languagemodel = [os.path.abspath(os.path.join(jasperpath.LIB_PATH, filename)) for filename in ("sentences.txt", "dictionary.dic", "languagemodel.lm")] vocabcompiler.compile(sentences, dictionary, languagemodel) # Initialize Mic self.mic = Mic(speak.newSpeaker(), stt.PocketSphinxSTT(), stt.newSTTEngine(stt_engine_type, api_key=api_key))
def __init__(self): # Set $JASPER_HOME if not os.getenv('VOICE'): os.environ["VOICE"] = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) # # for testing # if len(sys.argv) > 1 and "--local" in sys.argv[1:]: # from client.local_mic import Mic # else: # from client.mic import Mic # Change CWD to $JASPER_HOME/jasper/client client_path = os.path.join(os.getenv("VOICE"), "easyNav-Voice", "client") os.chdir(client_path) # Add $JASPER_HOME/jasper/client to sys.path sys.path.append(client_path) self.speaker = speaker.newSpeaker() #interprocess self.DISPATCHER_PORT = 9002 self.dispatcherClient = DispatcherClient(port=self.DISPATCHER_PORT)
def __init__(self): # Read config config_file = os.path.abspath(os.path.join(client_path, 'profile.yml')) logger.debug("Trying to read config file: '%s'", config_file) with open(config_file, "r") as f: self.config = yaml.safe_load(f) try: api_key = self.config['keys']['GOOGLE_SPEECH'] except KeyError: api_key = None try: stt_engine_type = self.config['stt_engine'] except KeyError: stt_engine_type = "sphinx" logger.warning("stt_engine not specified in profile, defaulting to '%s'", stt_engine_type) # Compile dictionary sentences, dictionary, languagemodel = [os.path.abspath(os.path.join(client_path, filename)) for filename in ("sentences.txt", "dictionary.dic", "languagemodel.lm")] vocabcompiler.compile(sentences, dictionary, languagemodel) # Initialize Mic self.mic = Mic(speak.newSpeaker(), stt.PocketSphinxSTT(), stt.newSTTEngine(stt_engine_type, api_key=api_key))
os.chdir(client_path) # Add $JASPER_HOME/jasper/client to sys.path sys.path.append(client_path) # Set $LD_LIBRARY_PATH os.environ["LD_LIBRARY_PATH"] = "/usr/local/lib" # Set $PATH path = os.getenv("PATH") if path: path = os.pathsep.join([path, "/usr/local/lib/"]) else: path = "/usr/local/lib/" os.environ["PATH"] = path speaker = speak.newSpeaker() def testConnection(): if Diagnostics.check_network_connection(): print "CONNECTED TO INTERNET" else: print "COULD NOT CONNECT TO NETWORK" speaker.say( "Warning: I was unable to connect to a network. Parts of the system may not work correctly, depending on your setup." ) def fail(message): traceback.print_exc() speaker.say(message)
os.chdir(client_path) # Add $JASPER_HOME/jasper/client to sys.path sys.path.append(client_path) # Set $LD_LIBRARY_PATH os.environ["LD_LIBRARY_PATH"] = "/usr/local/lib" # Set $PATH path = os.getenv("PATH") if path: path = os.pathsep.join([path, "/usr/local/lib/"]) else: path = "/usr/local/lib/" os.environ["PATH"] = path speaker = speak.newSpeaker() def testConnection(): if Diagnostics.check_network_connection(): print "CONNECTED TO INTERNET" else: print "COULD NOT CONNECT TO NETWORK" speaker.say( "Warning: I was unable to connect to a network. Parts of the system may not work correctly, depending on your setup.") def fail(message): traceback.print_exc() speaker.say(message) sys.exit(1)