blob: e807beb48e8439a30b59e78212e9f2505411106b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/usr/bin/env python2
# -*- coding: utf-8-*-
import os
import sys
# Set $JASPER_HOME
jasper_home = os.getenv("JASPER_HOME")
if not jasper_home or not os.path.exists(jasper_home):
if os.path.exists("/home/pi"):
jasper_home = "/home/pi"
os.environ["JASPER_HOME"] = jasper_home
else:
print("Error: $JASPER_HOME is not set.")
sys.exit(0)
# Change CWD to $JASPER_HOME/jasper/boot
os.chdir(os.path.join(os.getenv("JASPER_HOME"), "jasper", "boot"))
# 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
import traceback
lib_path = os.path.abspath('../client')
sys.path.append(lib_path)
from diagnose import Diagnostics
import vocabcompiler
import speaker as speak
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)
def configure():
try:
print "COMPILING DICTIONARY"
vocabcompiler.compile(
"../client/sentences.txt", "../client/dictionary.dic", "../client/languagemodel.lm")
print "STARTING CLIENT PROGRAM"
os.system("$JASPER_HOME/jasper/client/start.sh &")
except OSError:
print "BOOT FAILURE: OSERROR"
fail(
"There was a problem starting Jasper. You may be missing the language model and associated files. Please read the documentation to configure your Raspberry Pi.")
except IOError:
print "BOOT FAILURE: IOERROR"
fail(
"There was a problem starting Jasper. You may have set permissions incorrectly on some part of the filesystem. Please read the documentation to configure your Raspberry Pi.")
except:
print "BOOT FAILURE"
fail(
"There was a problem starting Jasper. 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 "=========================================="
speaker.say("Hello.... I am Jasper... Please wait one moment.")
testConnection()
configure()
|