Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- self._arecord = subprocess.Popen(self._cmd, stdout=subprocess.PIPE)
- def recordSound(duration = 1, sr = AUDIO_SAMPLE_RATE_HZ):
- recorder = Recorder(sample_rate_hz = sr)
- dumper = assembleArray(duration)
- with recorder, dumper:
- recorder.add_processor(dumper)
- while not dumper.is_done():
- time.sleep(0.1)
- byt_buffer_lst = dumper.byte_buffer
- byte_buffer = b''.join(byt_buffer_lst)
- dat = np.frombuffer(byte_buffer, np.int16)
- ## return sample rate in tuple to mimic wavfile read
- return((sr, dat))
Add Comment
Please, Sign In to add comment