diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-19 12:30:29 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-19 12:30:29 +0200 |
| commit | 3934c771b944e30e278f53be4480c6e5d24643bc (patch) | |
| tree | 585b2d90030548204cab1d47863fc67ef4a47f97 | |
| parent | 259c5798024d3a4136d55e6ffd2035b46df98fcb (diff) | |
| download | jasper-client-3934c771b944e30e278f53be4480c6e5d24643bc.tar.gz jasper-client-3934c771b944e30e278f53be4480c6e5d24643bc.zip | |
Replace JASPER_HOME with jasperpath.APP_PATH + os.pardir
| -rw-r--r-- | client/g2p.py | 4 | ||||
| -rw-r--r-- | client/test.py | 5 | ||||
| -rwxr-xr-x | jasper.py | 19 |
3 files changed, 11 insertions, 17 deletions
diff --git a/client/g2p.py b/client/g2p.py index 276f681..6e308ef 100644 --- a/client/g2p.py +++ b/client/g2p.py @@ -5,6 +5,8 @@ import subprocess import re import yaml +import jasperpath + PHONE_MATCH = re.compile(r'<s> (.*) </s>') FST_MODEL = None @@ -18,7 +20,7 @@ if os.path.exists(profile_path): FST_MODEL = profile['pocketsphinx']['fst_model'] if not FST_MODEL: - FST_MODEL = os.environ['JASPER_HOME'] + "/phonetisaurus/g014b2b.fst" + FST_MODEL = os.path.join(jasperpath.APP_PATH, os.pardir, 'phonetisaurus', 'g014b2b.fst') def parseLine(line): diff --git a/client/test.py b/client/test.py index a731951..49f3109 100644 --- a/client/test.py +++ b/client/test.py @@ -2,14 +2,11 @@ # -*- coding: utf-8-*- import os import sys - -if os.environ.get('JASPER_HOME') is None: - os.environ['JASPER_HOME'] = '/home/pi' - import unittest import argparse from mock import patch from urllib2 import URLError, urlopen + import test_mic import vocabcompiler import g2p @@ -10,12 +10,8 @@ logger = logging.getLogger(__name__) import yaml import argparse -# Set $JASPER_HOME -if not os.getenv('JASPER_HOME'): - os.environ["JASPER_HOME"] = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) - from client.diagnose import Diagnostics -from client import vocabcompiler, stt +from client import vocabcompiler, stt, jasperpath from client import speaker as speak from client.conversation import Conversation @@ -33,16 +29,15 @@ if args.local: else: from client.mic import Mic -# Change CWD to $JASPER_HOME/jasper/client -client_path = os.path.join(os.getenv("JASPER_HOME"), "jasper", "client") -os.chdir(client_path) -# Add $JASPER_HOME/jasper/client to sys.path -sys.path.append(client_path) +# Change CWD to jasperpath.LIB_PATH +os.chdir(jasperpath.LIB_PATH) +# Add jasperpath.LIB_PATH to sys.path +sys.path.append(jasperpath.LIB_PATH) class Jasper(object): def __init__(self): # Read config - config_file = os.path.abspath(os.path.join(client_path, 'profile.yml')) + config_file = os.path.abspath(os.path.join(jasperpath.LIB_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) @@ -59,7 +54,7 @@ class Jasper(object): 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")] + 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 |
