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_iter.py 541B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python3
  2. import sys
  3. import wave
  4. import rnnoise
  5. def in_iter(fname, chunk_sz=4096):
  6. with wave.open(fname, 'rb') as infp:
  7. while True:
  8. data = infp.readframes(chunk_sz)
  9. if len(data) == 0:
  10. return
  11. yield data
  12. rnn = rnnoise.RNNoise()
  13. with wave.open(sys.argv[1], 'rb') as infp:
  14. params = infp.getparams()
  15. with wave.open(sys.argv[2], 'wb') as outfp:
  16. outfp.setparams(params)
  17. for frames in rnn.iter_on(in_iter(sys.argv[1])):
  18. outfp.writeframes(frames)