summaryrefslogtreecommitdiff
path: root/client/mic.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-07-11 09:38:42 -0700
committerschneefux <schneefux+commit@schneefux.xyz>2014-07-11 09:38:42 -0700
commit43eebc44166da07388a2e932d1234090fda957ec (patch)
treed5cc1793a0b6269df71cce2b58ea099c60e4e455 /client/mic.py
parentea082f844a6748141aa61143421e4e9d0cc19bda (diff)
parent8a5e5ed385a5c467260c2f1b20816a66cebfc1c6 (diff)
downloadjasper-client-43eebc44166da07388a2e932d1234090fda957ec.tar.gz
jasper-client-43eebc44166da07388a2e932d1234090fda957ec.zip
Merge pull request #100 from astahlman/master
Platform independent audio output. Stop hardcoding /home/jasper.
Diffstat (limited to 'client/mic.py')
-rw-r--r--client/mic.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/client/mic.py b/client/mic.py
index d746ba1..f4b70df 100644
--- a/client/mic.py
+++ b/client/mic.py
@@ -22,17 +22,18 @@ class Mic:
speechRec = None
speechRec_persona = None
- def __init__(self, lmd, dictd, lmd_persona, dictd_persona, lmd_music=None, dictd_music=None):
+ def __init__(self, speaker, lmd, dictd, lmd_persona, dictd_persona, lmd_music=None, dictd_music=None):
"""
Initiates the pocketsphinx instance.
Arguments:
+ 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')
dictd_persona -- filename of the 'Persona' dictionary (.dic)
"""
-
+ self.speaker = speaker
hmdir = "/usr/local/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k"
if lmd_music and dictd_music:
@@ -237,7 +238,7 @@ class Mic:
if THRESHOLD == None:
THRESHOLD = self.fetchThreshold()
- os.system("aplay -D hw:1,0 ../static/audio/beep_hi.wav")
+ self.speaker.play("../static/audio/beep_hi.wav")
# prepare recording stream
audio = pyaudio.PyAudio()
@@ -267,7 +268,7 @@ class Mic:
if average < THRESHOLD * 0.8:
break
- os.system("aplay -D hw:1,0 ../static/audio/beep_lo.wav")
+ self.speaker.play("../static/audio/beep_lo.wav")
# save the audio data
stream.stop_stream()
@@ -291,6 +292,4 @@ class Mic:
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"):
# alter phrase before speaking
phrase = alteration.clean(phrase)
-
- os.system("espeak " + json.dumps(phrase) + OPTIONS)
- os.system("aplay -D hw:1,0 say.wav")
+ self.speaker.say(phrase)