From 083baa5d20b2e264fe185848a5c6a914d9defd1e Mon Sep 17 00:00:00 2001 From: Paul Warren Date: Sat, 11 Feb 2017 22:50:38 +1100 Subject: [PATCH] It VERKS! Now to learn morse! --- morse.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/morse.py b/morse.py index 4198893..3630565 100644 --- a/morse.py +++ b/morse.py @@ -10,6 +10,7 @@ class Morse: def play_letter(self, alphanum): self.play_sound(alphanum) + time.sleep(0.2) getattr(self, 'morse_' + alphanum)() self.wait_letter() while self.stream.is_active(): @@ -30,14 +31,15 @@ class Morse: def play_sound(self, alphanum): self.wf = wave.open("./audio/" + alphanum.upper()+ ".wav") - self.stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), - channels=wf.getnchannels(), - rate=wf.getframerate(), - output=True, - stream_callback=callback) + self.stream = self.p.open( + format=self.p.get_format_from_width(self.wf.getsampwidth()), + channels=self.wf.getnchannels(), + rate=self.wf.getframerate(), + output=True, + stream_callback=self.callback) self.stream.start_stream() - def callback(in_data, frame_count, time_info, stats): + def callback(self, in_data, frame_count, time_info, stats): data = self.wf.readframes(frame_count) return (data, pyaudio.paContinue)