Skip to content

Commit af31dc5

Browse files
committed
Change AbstractSpeaker.play() to use aplay due to issues with PyAudio playback
see jasperproject#188 for more info
1 parent b48a624 commit af31dc5

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

client/speaker.py

+5-16
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,11 @@ def is_available(cls):
4040
def say(self, phrase, *args):
4141
pass
4242

43-
def play(self, filename, chunksize=1024):
44-
f = wave.open(filename, 'rb')
45-
p = pyaudio.PyAudio()
46-
stream = p.open(format=p.get_format_from_width(f.getsampwidth()),
47-
channels=f.getnchannels(),
48-
rate=f.getframerate(),
49-
output=True)
50-
51-
data = f.readframes(chunksize)
52-
while data:
53-
stream.write(data)
54-
data = f.readframes(chunksize)
55-
56-
stream.stop_stream()
57-
stream.close()
58-
p.terminate()
43+
def play(self, filename):
44+
# FIXME: Use platform-independent audio-output here
45+
# See issue jasperproject/jasper-client#188
46+
cmd = ['aplay', str(filename)]
47+
subprocess.call(cmd)
5948

6049
class AbstractMp3Speaker(AbstractSpeaker):
6150
"""

0 commit comments

Comments
 (0)