diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-06-28 15:16:57 -0700 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-06-28 15:16:57 -0700 |
| commit | 3419eee951be8660f13b5d750a33b8e8ed64b425 (patch) | |
| tree | 210f4ec0bd14be447566195d0dffaf10182af9d2 /client | |
| parent | 02f3505cd6d585a24d79cca033f30ce88e972563 (diff) | |
| download | jasper-client-3419eee951be8660f13b5d750a33b8e8ed64b425.tar.gz jasper-client-3419eee951be8660f13b5d750a33b8e8ed64b425.zip | |
Changes suggested in CR.
Diffstat (limited to 'client')
| -rw-r--r-- | client/mic.py | 4 | ||||
| -rw-r--r-- | client/notifier.py | 2 | ||||
| -rw-r--r-- | client/speaker.py | 35 |
3 files changed, 30 insertions, 11 deletions
diff --git a/client/mic.py b/client/mic.py index f14ebc6..f4b70df 100644 --- a/client/mic.py +++ b/client/mic.py @@ -238,7 +238,7 @@ class Mic: if THRESHOLD == None: THRESHOLD = self.fetchThreshold() - self.speaker.playSound("../static/audio/beep_hi.wav") + self.speaker.play("../static/audio/beep_hi.wav") # prepare recording stream audio = pyaudio.PyAudio() @@ -268,7 +268,7 @@ class Mic: if average < THRESHOLD * 0.8: break - self.speaker.playSound("../static/audio/beep_lo.wav") + self.speaker.play("../static/audio/beep_lo.wav") # save the audio data stream.stop_stream() diff --git a/client/notifier.py b/client/notifier.py index 341ae04..7e6b0a2 100644 --- a/client/notifier.py +++ b/client/notifier.py @@ -1,5 +1,5 @@ import Queue -from modules import Gmail +#from modules import Gmail from apscheduler.scheduler import Scheduler import logging logging.basicConfig() diff --git a/client/speaker.py b/client/speaker.py index e7dc075..1b1255a 100644 --- a/client/speaker.py +++ b/client/speaker.py @@ -1,22 +1,33 @@ """ A Speaker handles audio output from Jasper to the user -""" -import os, json -class PiSpeaker: +Speaker methods: + say - output 'phrase' as speech + play - play the audio in 'filename' + isAvailable - returns True if the platform supports this implementation +""" +import os +import json +class eSpeakSpeaker: + """ + Uses the eSpeak speech synthesizer included in the Jasper disk image + """ @classmethod def isAvailable(cls): return os.system("which espeak") == 0 def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): os.system("espeak " + json.dumps(phrase) + OPTIONS) - self.playSound("say.wav") + self.play("say.wav") - def playSound(self, filename): + def play(self, filename): os.system("aplay -D hw:1,0 " + filename) -class MacSpeaker: +class saySpeaker: + """ + Uses the OS X built-in 'say' command + """ @classmethod def isAvailable(cls): @@ -28,11 +39,19 @@ class MacSpeaker: def say(self, phrase): os.system("say " + self.shellquote(phrase)) - def playSound(self, filename): + def play(self, filename): os.system("afplay " + filename) def newSpeaker(): - for cls in [PiSpeaker, MacSpeaker]: + """ + Returns: + A speaker implementation available on the current platform + + Raises: + ValueError if no speaker implementation is supported on this platform + """ + + for cls in [eSpeakSpeaker, saySpeaker]: if cls.isAvailable(): return cls() raise ValueError("Platform is not supported") |
