summaryrefslogtreecommitdiff
path: root/jasper.py
diff options
context:
space:
mode:
Diffstat (limited to 'jasper.py')
-rwxr-xr-xjasper.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/jasper.py b/jasper.py
index 62713ee..5f08e68 100755
--- a/jasper.py
+++ b/jasper.py
@@ -4,15 +4,12 @@ import sys
import traceback
import shutil
import logging
-logging.basicConfig()
-logger = logging.getLogger(__name__)
import yaml
import argparse
from client.diagnose import Diagnostics
-from client import vocabcompiler, stt, jasperpath
-from client import speaker as speak
+from client import vocabcompiler, tts, stt, jasperpath
from client.conversation import Conversation
parser = argparse.ArgumentParser(description='Jasper Voice Control Center')
@@ -21,9 +18,6 @@ parser.add_argument('--no-network-check', action='store_true', help='Disable the
parser.add_argument('--debug', action='store_true', help='Show debug messages')
args = parser.parse_args()
-if args.debug:
- logger.setLevel(logging.DEBUG)
-
if args.local:
from client.local_mic import Mic
else:
@@ -36,9 +30,10 @@ sys.path.append(jasperpath.LIB_PATH)
class Jasper(object):
def __init__(self):
+ self._logger = logging.getLogger(__name__)
# Read config
config_file = os.path.abspath(os.path.join(jasperpath.LIB_PATH, 'profile.yml'))
- logger.debug("Trying to read config file: '%s'", config_file)
+ self._logger.debug("Trying to read config file: '%s'", config_file)
with open(config_file, "r") as f:
self.config = yaml.safe_load(f)
@@ -51,14 +46,21 @@ class Jasper(object):
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)
+ self._logger.warning("stt_engine not specified in profile, defaulting to '%s'", stt_engine_type)
+
+ try:
+ tts_engine_slug = self.config['tts_engine']
+ except KeyError:
+ tts_engine_slug = tts.get_default_engine_slug()
+ logger.warning("tts_engine not specified in profile, defaulting to '%s'", tts_engine_slug)
+ tts_engine_class = tts.get_engine_by_slug(tts_engine_slug)
# 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))
+ self.mic = Mic(tts_engine_class(), stt.PocketSphinxSTT(), stt.newSTTEngine(stt_engine_type, api_key=api_key))
def run(self):
if 'first_name' in self.config:
@@ -77,6 +79,12 @@ if __name__ == "__main__":
print " Copyright 2013 Shubhro Saha & Charlie Marsh "
print "==========================================================="
+ logging.basicConfig()
+ logger = logging.getLogger()
+
+ if args.debug:
+ logger.setLevel(logging.DEBUG)
+
if not args.no_network_check and not Diagnostics.check_network_connection():
logger.warning("Network not connected. This may prevent Jasper from running properly.")