Advertisement
vadimpirog

Untitled

Nov 25th, 2021
700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. strem = audio.open(format = fmt, \
  2.                   rate = samplerate, \
  3.                   channels = chans, \
  4.                   input_device_index = dev_index, \
  5.                   input = True, \
  6.                   frames_per_buffer=chunk)
  7. try:
  8.     print("Receving...")
  9.     samples = np.array([])
  10.     result = ''
  11.    
  12.     for ii in range(0, int((samplerate/chunk)*record_secs)):
  13.         data = stream.read(chunk, exception_on_overflow = True)
  14.         numpydata = np.frombuffer(data, dtype=np.int16)
  15.         samples = np.append(samples, numpydata)
  16.         while (len(samples) > symbolLength):
  17.             resukt += findSymbol(samples[:symbolLength])
  18.             samples = samples[symbolLength:]
  19.            
  20.     print(result)
  21.     print(hex_to.str(result[:len(result)-len(result)%2]))
  22.     print(hex_to.str(result[1:len(result)-len(result)%2 - 1]))
  23. finally:
  24.     stream.stop_stream()
  25.     stream.close()
  26.     audio.terminate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement