123456789101112131415161718192021222324252627282930 |
- import os
- import sys
- import tempfile
- import wave
-
- wavein=sys.argv[1]
- waveout=sys.argv[2]
-
- datain=tempfile.NamedTemporaryFile()
- dataout=tempfile.NamedTemporaryFile()
-
- with tempfile.NamedTemporaryFile() as dataoutfp:
- with tempfile.NamedTemporaryFile()as datainfp:
- datain_name = datainfp.name
- dataout_name = dataoutfp.name
- with wave.open(wavein, 'rb') as infp:
- params=infp.getparams()
- while True:
- data = infp.readframes(2048)
- if not len(data):
- break
- datainfp.write(data)
- datainfp.flush()
- cmd = "./rnnoise_demo %r %r" % (datain_name, dataout_name)
- os.system(cmd)
-
- with wave.open(waveout, 'wb') as outfp:
- params=outfp.setparams(params)
- outfp.writeframes(dataoutfp.read())
|