Commit 69bcb6cd authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch '111-evs-decoding-should-use-PCM' into 'main'

EVS decoding should use PCM output extension

See merge request !210
parents 9d4251f7 02d0a71a
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -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,