not closing it
This commit is contained in:
+6
-8
@@ -41,7 +41,6 @@ class Audio:
|
|||||||
def stopRecord(self, play=True, save=False):
|
def stopRecord(self, play=True, save=False):
|
||||||
print("* done recording")
|
print("* done recording")
|
||||||
self.recordStream.stop_stream()
|
self.recordStream.stop_stream()
|
||||||
self.recordStream.close()
|
|
||||||
self.frames = []
|
self.frames = []
|
||||||
|
|
||||||
if save:
|
if save:
|
||||||
@@ -49,9 +48,6 @@ class Audio:
|
|||||||
if play:
|
if play:
|
||||||
self._playFrames()
|
self._playFrames()
|
||||||
|
|
||||||
def terminate(self):
|
|
||||||
self.pyaudio.terminate()
|
|
||||||
|
|
||||||
def _saveFile(self):
|
def _saveFile(self):
|
||||||
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
|
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
|
||||||
wf.setnchannels(RESPEAKER_CHANNELS)
|
wf.setnchannels(RESPEAKER_CHANNELS)
|
||||||
@@ -62,7 +58,7 @@ class Audio:
|
|||||||
wf.close()
|
wf.close()
|
||||||
|
|
||||||
def _playFrames(self):
|
def _playFrames(self):
|
||||||
self.playbackStream = self.pyaudio.open(
|
playbackStream = self.pyaudio.open(
|
||||||
format=self.pyaudio.get_format_from_width(RESPEAKER_WIDTH),
|
format=self.pyaudio.get_format_from_width(RESPEAKER_WIDTH),
|
||||||
channels=RESPEAKER_CHANNELS,
|
channels=RESPEAKER_CHANNELS,
|
||||||
rate=RESPEAKER_RATE,
|
rate=RESPEAKER_RATE,
|
||||||
@@ -71,8 +67,10 @@ class Audio:
|
|||||||
|
|
||||||
# loop through self.frames and play audio
|
# loop through self.frames and play audio
|
||||||
for frame in self.frames:
|
for frame in self.frames:
|
||||||
self.playbackStream.write(frame)
|
playbackStream.write(frame)
|
||||||
|
|
||||||
# cleanup stuff
|
# cleanup stuff
|
||||||
self.playbackStream.stop_stream()
|
playbackStream.stop_stream()
|
||||||
self.playbackStream.close()
|
|
||||||
|
def terminate(self):
|
||||||
|
self.pyaudio.terminate()
|
||||||
|
|||||||
Reference in New Issue
Block a user