Commit eff8c567 authored by Jan Kiene's avatar Jan Kiene
Browse files

fix odg

parent d24aaa3d
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts"))
import numpy as np
import pyaudio3dtools
import pyivastest
from constants import ODG_PATTERN
from .constants import ODG_PATTERN


def cmp_pcm(
@@ -108,13 +108,15 @@ def cmp_pcm(

    if get_odg:
        reason += "\n"
        print(orig_file)
        orig_sig, _ = pyaudio3dtools.audiofile.readfile(orig_file)
        for n in range(nchannels):
            pqeval_output_ref = pqevalaudio_wrapper(s1[:, n], orig_sig[:, n])
            pqeval_output_cmp = pqevalaudio_wrapper(s2[:, n], orig_sig[:, n])
            pqeval_output_ref = pqevalaudio_wrapper(s1[:, n], orig_sig[:, n], fs)
            pqeval_output_cmp = pqevalaudio_wrapper(s2[:, n], orig_sig[:, n], fs)

            match_ref = re.match(ODG_PATTERN, pqeval_output_ref)
            match_cmp = re.match(ODG_PATTERN, pqeval_output_cmp)
            print(pqeval_output_ref)
            match_ref = re.search(ODG_PATTERN, pqeval_output_ref)
            match_cmp = re.search(ODG_PATTERN, pqeval_output_cmp)

            odg_ref = float(match_ref.groups()[0])
            odg_cmp = float(match_cmp.groups()[0])
@@ -136,15 +138,21 @@ def pqevalaudio_wrapper(
        tmp_file_ref = str(tmp_dir.joinpath("ref.wav"))
        tmp_file_eval = str(tmp_dir.joinpath("eval.wav"))

        pyaudio3dtools.audiofile.writefile(tmp_file_ref, ref_sig, fs)
        pyaudio3dtools.audiofile.writefile(tmp_file_eval, eval_sig, fs)
        # PQevalAudio neeeds 48 kHz sampling rate
        r48 = np.clip( pyaudio3dtools.audioarray.resample(ref_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16)
        t48 = np.clip( pyaudio3dtools.audioarray.resample(eval_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16)

        pyaudio3dtools.audiofile.writefile(tmp_file_ref, r48, 48000)
        pyaudio3dtools.audiofile.writefile(tmp_file_eval, t48, 48000)

        cmd = ["PQevalAudio", tmp_file_ref, tmp_file_eval]

        print(cmd)
        result = subprocess.run(cmd, capture_output=True)
        if result.returncode != 0:
            raise RuntimeError("Error running PQevalaudio")
            raise RuntimeError(f"Error running PQevalaudio: {result.stderr}")

        print(result.stdout.decode("utf8"))
        return result.stdout.decode("utf8")


+1 −0
Original line number Diff line number Diff line
@@ -353,6 +353,7 @@ def test_param_file_tests(
            allow_differing_lengths=allow_differing_lengths,
            get_ssnr=get_ssnr,
            get_odg=get_odg,
            orig_file=Path(reference_path).joinpath(testv_file)
        )
        md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config)