diff options
Diffstat (limited to 'boot')
| -rwxr-xr-x | boot/boot.py | 18 | ||||
| -rwxr-xr-x | boot/boot.sh | 15 | ||||
| -rw-r--r-- | boot/test.py | 10 |
3 files changed, 33 insertions, 10 deletions
diff --git a/boot/boot.py b/boot/boot.py index 456dd12..12b60eb 100755 --- a/boot/boot.py +++ b/boot/boot.py @@ -3,12 +3,16 @@ import os import json import urllib2 +import sys import vocabcompiler +import traceback -def say(phrase, OPTIONS = " -vdefault+m3 -p 40 -s 160 --stdout > ../static/audio/say.wav"): - os.system("espeak " + json.dumps(phrase) + OPTIONS) - os.system("aplay -D hw:1,0 ../static/audio/say.wav") +lib_path = os.path.abspath('../client') +sys.path.append(lib_path) + +import speaker as speak +speaker = speak.newSpeaker() def configure(): try: @@ -19,17 +23,17 @@ def configure(): vocabcompiler.compile("../client/sentences.txt", "../client/dictionary.dic", "../client/languagemodel.lm") print "STARTING CLIENT PROGRAM" - os.system("/home/pi/jasper/client/start.sh &") + os.system("$JASPER_HOME/jasper/client/start.sh &") except: - print "COULD NOT CONNECT TO NETWORK" - say("Hello, I could not connect to a network. Please read the documentation to configure your Raspberry Pi.") + traceback.print_exc() + speaker.say("Hello, I could not connect to a network. Please read the documentation to configure your Raspberry Pi.") if __name__ == "__main__": print "==========STARTING JASPER CLIENT==========" print "==========================================" print "COPYRIGHT 2013 SHUBHRO SAHA, CHARLIE MARSH" print "==========================================" - say("Hello.... I am Jasper... Please wait one moment.") + speaker.say("Hello.... I am Jasper... Please wait one moment.") configure() diff --git a/boot/boot.sh b/boot/boot.sh index 5ea1b3d..e712c0d 100755 --- a/boot/boot.sh +++ b/boot/boot.sh @@ -1,6 +1,17 @@ -cd /home/pi/jasper/boot/ +#!/bin/bash +if [[ -z "$JASPER_HOME" ]]; then + if [[ -d "/home/pi" ]]; then + JASPER_HOME="/home/pi" + export JASPER_HOME; + else + echo "Error: \$JASPER_HOME is not set." + exit 0; + fi +fi + +cd $JASPER_HOME/jasper/boot LD_LIBRARY_PATH="/usr/local/lib" export LD_LIBRARY_PATH PATH=$PATH:/usr/local/lib/ export PATH -python boot.py &
\ No newline at end of file +python boot.py & diff --git a/boot/test.py b/boot/test.py index c6bd3ff..af5f982 100644 --- a/boot/test.py +++ b/boot/test.py @@ -1,4 +1,8 @@ import os + +if os.environ.get('JASPER_HOME') is None: + os.environ['JASPER_HOME'] = '/home/pi' + import sys import unittest from mock import patch @@ -12,6 +16,10 @@ sys.path.append(mod_path) import g2p +class UnorderedList(list): + def __eq__(self, other): + return sorted(self) == sorted(other) + class TestVocabCompiler(unittest.TestCase): @@ -33,7 +41,7 @@ class TestVocabCompiler(unittest.TestCase): # 'words' is appended with ['MUSIC', 'SPOTIFY'] # so must be > 2 to have received WORDS from modules - translateWords.assert_called_once_with(words) + translateWords.assert_called_once_with(UnorderedList(words)) self.assertTrue(text2lm.called) os.remove(sentences) os.remove(dictionary) |
