summaryrefslogtreecommitdiff
path: root/client/mic.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-06-08 20:39:35 -0700
committerschneefux <schneefux+commit@schneefux.xyz>2014-06-21 12:39:11 -0700
commit84a92e5327997815488276021e5498f7681ab2d7 (patch)
tree972b154650d9a4ae3bd0a77b1ace36d403457053 /client/mic.py
parent1744368ac1889fe0767f04d55e8f928553c8db1c (diff)
downloadjasper-client-84a92e5327997815488276021e5498f7681ab2d7.tar.gz
jasper-client-84a92e5327997815488276021e5498f7681ab2d7.zip
Stop hardcoding /home/jasper and abstract out mic.say for multiplatform support
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..0c41df9 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 -- used to output audio
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.playSound("../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.playSound("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)