Skip to content

Commit

Permalink
Change AbstractSpeaker.play() to use aplay due to issues with PyAudio…
Browse files Browse the repository at this point in the history
… playback

see jasperproject#188 for more info
  • Loading branch information
Holzhaus committed Sep 24, 2014
1 parent b8d8957 commit fc0748d
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions client/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,11 @@ def is_available(cls):
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):
"""
Expand Down

0 comments on commit fc0748d

Please sign in to comment.