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_orig.py 844B

123456789101112131415161718192021222324252627282930
  1. import os
  2. import sys
  3. import tempfile
  4. import wave
  5. wavein=sys.argv[1]
  6. waveout=sys.argv[2]
  7. datain=tempfile.NamedTemporaryFile()
  8. dataout=tempfile.NamedTemporaryFile()
  9. with tempfile.NamedTemporaryFile() as dataoutfp:
  10. with tempfile.NamedTemporaryFile()as datainfp:
  11. datain_name = datainfp.name
  12. dataout_name = dataoutfp.name
  13. with wave.open(wavein, 'rb') as infp:
  14. params=infp.getparams()
  15. while True:
  16. data = infp.readframes(2048)
  17. if not len(data):
  18. break
  19. datainfp.write(data)
  20. datainfp.flush()
  21. cmd = "./rnnoise_demo %r %r" % (datain_name, dataout_name)
  22. os.system(cmd)
  23. with wave.open(waveout, 'wb') as outfp:
  24. params=outfp.setparams(params)
  25. outfp.writeframes(dataoutfp.read())