Skip to content

Commit

Permalink
tweaks to pathing
Browse files Browse the repository at this point in the history
  • Loading branch information
sammachin committed Jan 8, 2016
1 parent bdad4e3 commit b2b5ba3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Main_RPi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
recorded = False
servers = ["127.0.0.1:11211"]
mc = Client(servers, debug=1)
path = os.path.realpath(__file__).rstrip(os.path.basename(__file__))

def gettoken():
token = mc.get("access_token")
Expand Down Expand Up @@ -60,7 +61,7 @@ def alexa():
"format": "audio/L16; rate=16000; channels=1"
}
}
inf = open('recording.wav')
inf = open(path+'recording.wav')
files = [
('file', ('request', json.dumps(d), 'application/json; charset=UTF-8')),
('file', ('audio', inf, 'audio/L16; rate=16000; channels=1'))
Expand All @@ -75,11 +76,11 @@ def alexa():
for d in data:
if (len(d) >= 1024):
audio = d.split('\r\n\r\n')[1].rstrip('--')
f = open("response.mp3", 'wb')
f = open(path+"response.mp3", 'wb')
f.write(audio)
f.close()
GPIO.output(25, GPIO.LOW)
os.system('mpg123 -q 1sec.mp3 response.mp3')
os.system('mpg123 -q {}1sec.mp3 {}response.mp3'.format(path, path))
GPIO.output(24, GPIO.LOW)
else:
GPIO.output(lights, GPIO.LOW)
Expand All @@ -99,7 +100,7 @@ def start():
if val != last:
last = val
if val == 1 and recorded == True:
rf = open('recording.wav', 'w')
rf = open(path+'recording.wav', 'w')
rf.write(audio)
rf.close()
inp = None
Expand Down Expand Up @@ -130,7 +131,7 @@ def start():
GPIO.setup(lights, GPIO.OUT)
GPIO.output(lights, GPIO.LOW)
token = gettoken()
os.system('mpg123 -q 1sec.mp3 hello.mp3')
os.system('mpg123 -q {}1sec.mp3 {}hello.mp3'.format(path, path))
for x in range(0, 3):
time.sleep(.1)
GPIO.output(24, GPIO.HIGH)
Expand Down

0 comments on commit b2b5ba3

Please sign in to comment.