Loading other/lp16k.py +8 −6 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ from ivas_processing_scripts.audiotools.audio import fromfile from ivas_processing_scripts.audiotools.audiofile import write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu from ivas_processing_scripts.utils import progressbar_update, spinner from ivas_processing_scripts.audiotools.audioarray import trim def lp16k(in_file, out_file): Loading @@ -19,21 +20,22 @@ def lp16k(in_file, out_file): f"Unsupported sampling rate {x.fs//1000} kHz for input file {in_file} - only 48 kHz is supported!" ) # save length of audio since resampling can alter the length by one sample due to rounding len_signal = len(x.audio) # resample ITU only returns the audio array # but uses the sampling rate stored in the audio object # so we need to correctly set it after each call x.audio = resample_itu(x, 96000) x.fs = 96000 x.audio = resample_itu(x, 32000) x.fs = 32000 x.audio = resample_itu(x, 96000) x.fs = 96000 x.audio = resample_itu(x, 48000) x.fs = 48000 if len_signal != len(x.audio): # padding should usually not happen since the resampling only rounds up x.audio = trim(x.audio, x.fs, (0, len(x.audio)-len_signal), samples=True, pad_noise=True) write(out_file, x.audio, x.fs) Loading Loading
other/lp16k.py +8 −6 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ from ivas_processing_scripts.audiotools.audio import fromfile from ivas_processing_scripts.audiotools.audiofile import write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu from ivas_processing_scripts.utils import progressbar_update, spinner from ivas_processing_scripts.audiotools.audioarray import trim def lp16k(in_file, out_file): Loading @@ -19,21 +20,22 @@ def lp16k(in_file, out_file): f"Unsupported sampling rate {x.fs//1000} kHz for input file {in_file} - only 48 kHz is supported!" ) # save length of audio since resampling can alter the length by one sample due to rounding len_signal = len(x.audio) # resample ITU only returns the audio array # but uses the sampling rate stored in the audio object # so we need to correctly set it after each call x.audio = resample_itu(x, 96000) x.fs = 96000 x.audio = resample_itu(x, 32000) x.fs = 32000 x.audio = resample_itu(x, 96000) x.fs = 96000 x.audio = resample_itu(x, 48000) x.fs = 48000 if len_signal != len(x.audio): # padding should usually not happen since the resampling only rounds up x.audio = trim(x.audio, x.fs, (0, len(x.audio)-len_signal), samples=True, pad_noise=True) write(out_file, x.audio, x.fs) Loading