better ordering

This commit is contained in:
talksik
2023-04-27 15:22:37 -07:00
parent d94f64d2fe
commit b0cafb4d44
2 changed files with 4 additions and 5 deletions
+2 -3
View File
@@ -23,8 +23,6 @@ class Audio:
def readCallback(self, out_data, frame_count, time_info, status):
self.frames.append(out_data)
# If len(data) is less than requested frame_count, PyAudio automatically
# assumes the stream is finished, and the stream stops.
return (out_data, pyaudio.paContinue)
def isRecording(self):
@@ -32,6 +30,7 @@ class Audio:
def startRecord(self):
print("* recording stream started")
self.frames = []
self.recordStream = self.pyaudio.open(
rate=RESPEAKER_RATE,
format=self.pyaudio.get_format_from_width(RESPEAKER_WIDTH),
@@ -39,10 +38,10 @@ class Audio:
input=True,
input_device_index=RESPEAKER_INDEX,
start=False,
frames_per_buffer=CHUNK,
stream_callback=self.readCallback,)
self.recordStream.start_stream()
self._isRecording = True
self.frames = []
def stopRecord(self, play=True, save=False):
print("* done recording")
+2 -2
View File
@@ -40,9 +40,9 @@ while True:
if state:
if audioInstance.isRecording():
audioInstance.stopRecord()
turnOffLED()
audioInstance.stopRecord()
else:
if not audioInstance.isRecording():
audioInstance.startRecord()
turnOnLED()
audioInstance.startRecord()