From 84a92e5327997815488276021e5498f7681ab2d7 Mon Sep 17 00:00:00 2001 From: schneefux Date: Sun, 8 Jun 2014 20:39:35 -0700 Subject: Stop hardcoding /home/jasper and abstract out mic.say for multiplatform support --- boot/boot.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'boot/boot.py') diff --git a/boot/boot.py b/boot/boot.py index 59217ec..fcaeedd 100755 --- a/boot/boot.py +++ b/boot/boot.py @@ -1,14 +1,16 @@ #!/usr/bin/env python -import os, json +import os, sys import urllib2 import yaml - import vocabcompiler +import traceback + +lib_path = os.path.abspath('../client') +sys.path.append(lib_path) -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") +import speaker as speak +speaker = speak.newSpeaker() def configure(): try: @@ -19,17 +21,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() -- cgit v1.3.1 From 18c02563c04f77e1732194d74e537787247918b9 Mon Sep 17 00:00:00 2001 From: schneefux Date: Sat, 21 Jun 2014 13:11:56 -0700 Subject: Clean up before pull request. --- boot/boot.py | 3 ++- client/mic.py | 4 ++-- client/speaker.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'boot/boot.py') diff --git a/boot/boot.py b/boot/boot.py index fcaeedd..245bd4d 100755 --- a/boot/boot.py +++ b/boot/boot.py @@ -1,6 +1,7 @@ #!/usr/bin/env python -import os, sys +import os +import sys import urllib2 import yaml import vocabcompiler diff --git a/client/mic.py b/client/mic.py index 0c41df9..f14ebc6 100644 --- a/client/mic.py +++ b/client/mic.py @@ -27,7 +27,7 @@ class Mic: Initiates the pocketsphinx instance. Arguments: - speaker -- used to output audio + speaker -- handles platform-independent audio output lmd -- filename of the full language model dictd -- filename of the full dictionary (.dic) lmd_persona -- filename of the 'Persona' language model (containing, e.g., 'Jasper') @@ -268,7 +268,7 @@ class Mic: if average < THRESHOLD * 0.8: break - self.speaker.playSound("beep_lo.wav") + self.speaker.playSound("../static/audio/beep_lo.wav") # save the audio data stream.stop_stream() diff --git a/client/speaker.py b/client/speaker.py index 304b426..f2d4ab7 100644 --- a/client/speaker.py +++ b/client/speaker.py @@ -1,5 +1,5 @@ """ -A Speaker handles output from Jasper to the user. +A Speaker handles audio output from Jasper to the user """ import os, json -- cgit v1.3.1