diff --git a/ivas_processing_scripts/processing/ivas.py b/ivas_processing_scripts/processing/ivas.py index bab205a845c538cfb6591142539ceb064b5b5c1b..972f0c963afd78532b94e6823747e5e52e42d93b 100755 --- a/ivas_processing_scripts/processing/ivas.py +++ b/ivas_processing_scripts/processing/ivas.py @@ -37,7 +37,7 @@ from pathlib import Path from typing import Optional, Tuple, Union from ivas_processing_scripts.audiotools import audio -from ivas_processing_scripts.audiotools.audiofile import parse_wave_header, read +from ivas_processing_scripts.audiotools.audiofile import parse_wave_header, read, write from ivas_processing_scripts.audiotools.constants import IVAS_FRAME_LEN_MS from ivas_processing_scripts.audiotools.utils import truncate_trajectory_3dof from ivas_processing_scripts.audiotools.wrappers.dlyerr_2_errpat import dlyerr_2_errpat @@ -133,6 +133,10 @@ class IVAS(Processing): bitstream_noerror = bitstream bitstream, voip = self.simulate_tx(in_file, bitstream, logger) + # change suffix to PCM for EVS decoding mode + if getattr(self, "use_evs_dec", None): + out_file = out_file.with_suffix(".pcm") + # decode twice with and without bitstream errors self.dec(bitstream, out_file, voip=voip, logger=logger) if bitstream_noerror != bitstream and self.tx_condition: @@ -141,6 +145,19 @@ class IVAS(Processing): ) self.dec(bitstream_noerror, out_file_unprocessed, voip=False, logger=logger) + # convert PCM back to WAV in case of EVS decoding + if getattr(self, "use_evs_dec", None): + out_file_orig = out_file.with_suffix(".wav") + data, fs = read(out_file, self.out_fmt.num_channels, self.out_fs) + write(out_file_orig, data, fs) + + if bitstream_noerror != bitstream and self.tx_condition: + out_file_unprocessed_orig = out_file_unprocessed.with_suffix(".wav") + data, fs = read( + out_file_unprocessed, self.out_fmt.num_channels, self.out_fs + ) + write(out_file_unprocessed_orig, data, fs) + def enc( self, in_file: Path, @@ -232,7 +249,7 @@ class IVAS(Processing): # done this way to ensure `output_format` is replaced in the correct position cmd.remove("-stereo_dmx_evs") cmd[cmd.index("-stereo")] = "-stereo_dmx_evs" - self.use_evs_dec = True # signal the decoder to use EVS commandline + self.use_evs_dec = True # signal the decoder to use EVS commandline run(cmd, logger=logger)