def start_recording(): global is_recording, current_audio_file is_recording = True time_stamp = datetime.now() filename = time_stamp.strftime('%Y_%m_%d_%H_%M_%S') + ".wav" print("Start recording") rec = Recorder(channels=2) current_audio_file = rec.open(filename, 'wb') current_audio_file.start_recording() threading.Timer(1, sound).start()
def run(self): ''' record ''' print("Thread start") micRecorder = Recorder(channels=1) datetime_string = datetime.now().strftime("%d%m%Y_%H%M%S") filename = "record_" + datetime_string + ".wav" with micRecorder.open("records/testing/" + filename, 'wb') as recfile: recfile.start_recording() time.sleep(10.0) recfile.stop_recording() LiveFFTWidget.stopRecord = 0 print("Recording complete")
class ButtonRecorder(object): def __init__(self, filename=None, device=0): self.filename = filename self.rec = Recorder(channels=1, device=device) def set_device_index(self, index): self.rec.set_device(index) def set_file_name(self, filename): self.filename = filename def on_released(self): if (self.filename != None): self.recfile.stop_recording() self.recfile.close() def on_pressed(self): if (self.filename != None): print(self.filename) self.recfile = self.rec.open(self.filename, 'wb') self.recfile.start_recording()
def run(self): ''' record ''' print("Thread start") micRecorder = Recorder(channels=1) datetime_string = datetime_to_string() filename = "record_" + datetime_string + ".wav" with micRecorder.open("records/" + filename, 'wb') as recfile: recfile.start_recording() #time.sleep(10.0) while (LiveFFTWidget.stopRecord != 1): pass recfile.stop_recording() LiveFFTWidget.stopRecord = 0 VarManager.audioPath = "records/" + filename VarManager.audioUploaded = False print(VarManager.audioPath) print("Recording complete")