From d71c77460f8eb2564189b4695f4d1187beb8a8b2 Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 19 Sep 2014 15:17:44 +0200 Subject: Change AbstractSpeaker.play() to use aplay due to issues with PyAudio playback see jasperproject/jasper-client#188 for more info --- client/speaker.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/client/speaker.py b/client/speaker.py index df63eee..54a039f 100644 --- a/client/speaker.py +++ b/client/speaker.py @@ -40,22 +40,11 @@ class AbstractSpeaker(object): def say(self, phrase, *args): pass - def play(self, filename, chunksize=1024): - f = wave.open(filename, 'rb') - p = pyaudio.PyAudio() - stream = p.open(format=p.get_format_from_width(f.getsampwidth()), - channels=f.getnchannels(), - rate=f.getframerate(), - output=True) - - data = f.readframes(chunksize) - while data: - stream.write(data) - data = f.readframes(chunksize) - - stream.stop_stream() - stream.close() - p.terminate() + def play(self, filename): + # FIXME: Use platform-independent audio-output here + # See issue jasperproject/jasper-client#188 + cmd = ['aplay', str(filename)] + subprocess.call(cmd) class AbstractMp3Speaker(AbstractSpeaker): """ -- cgit v1.3.1