summaryrefslogtreecommitdiff
path: root/boot/boot.py
blob: 317b4c09bc3ed14b1f16452c8b29298bd67bd192 (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
#!/usr/bin/env python

import os, json
import urllib2
import subprocess
import yaml
from wifi import *

import vocabcompiler

def say(phrase, OPTIONS = " -vdefault+m3 -p 40 -s 160 --stdout > say.wav"):
    os.system("espeak " + json.dumps(phrase) + OPTIONS)
    os.system("aplay -D hw:1,0 say.wav")

def configure():
    try:
        urllib2.urlopen("http://www.google.com").getcode()

        print "CONNECTED TO INTERNET"
        print "COMPILING DICTIONARY"
        vocabcompiler.compile()

        print "STARTING CLIENT PROGRAM"
        os.system("/home/pi/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.")
        os.system("sudo shutdown -r now")

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.")
    configure()