Guest User

Untitled

a guest
Mar 23rd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. self._arecord = subprocess.Popen(self._cmd, stdout=subprocess.PIPE)
  2.  
  3. def recordSound(duration = 1, sr = AUDIO_SAMPLE_RATE_HZ):
  4.  
  5. recorder = Recorder(sample_rate_hz = sr)
  6.  
  7. dumper = assembleArray(duration)
  8.  
  9. with recorder, dumper:
  10.  
  11. recorder.add_processor(dumper)
  12.  
  13. while not dumper.is_done():
  14.  
  15. time.sleep(0.1)
  16.  
  17.  
  18.  
  19. byt_buffer_lst = dumper.byte_buffer
  20.  
  21. byte_buffer = b''.join(byt_buffer_lst)
  22.  
  23. dat = np.frombuffer(byte_buffer, np.int16)
  24.  
  25. ## return sample rate in tuple to mimic wavfile read
  26.  
  27. return((sr, dat))
Add Comment
Please, Sign In to add comment