Python wrapper for Xiph.org rnnoise ( https://gitlab.xiph.org/xiph/rnnoise )
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

demo.py 696B

12345678910111213141516171819202122
  1. import rnnoise
  2. import sys
  3. import wave
  4. rnn = rnnoise.RNNoise()
  5. with wave.open(sys.argv[1], 'rb') as infp:
  6. with wave.open(sys.argv[2], 'wb') as outfp:
  7. outfp.setparams(infp.getparams())
  8. buf = b''
  9. for i in range(infp.getnframes()):
  10. dataframe = infp.readframes(10)
  11. buf += dataframe
  12. while len(buf) >= (rnn.frame_size*2):
  13. res = rnn.process_frame(buf[:rnn.frame_size*2])
  14. outfp.writeframes(res)
  15. buf = buf[rnn.frame_size*2:]
  16. if len(buf):
  17. lenbuf = len(buf)
  18. buf += bytes(rnn.frame_size*2 - lenbuf)
  19. outfp.writeframes(rnn.process_frame(buf)[:lenbuf])