Commit d898cda0 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

add SSNR to batch_comp_audio.py

parent 1e349a32
Loading
Loading
Loading
Loading
Loading
+42 −35
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ def main(args):
                    repeat(fol2),
                    repeat(outputs),
                    repeat(tool),
                    repeat(test_offset_ms)
                    repeat(test_offset_ms),
                )

        if args.sort:
@@ -164,10 +164,17 @@ def compare_files(f, fol1, fol2, outputs_dict, tool, test_offset_ms):
        s2, fs2 = readfile(f2, outdtype="int16")
        cmp_result = compare(s1, s2, fs1, per_frame=False, get_mld=True)
        tool_output = cmp_result["MLD"]
    elif tool == "ssnr":
        s1, fs1 = readfile(f1, outdtype="int16")
        s2, fs2 = readfile(f2, outdtype="int16")
        cmp_result = compare(s1, s2, fs1, per_frame=False, get_ssnr=True)
        tool_output = cmp_result["SSNR"]
    elif tool == "pyaudio3dtools":
        s1, fs1 = readfile(f1, outdtype="int16")
        s2, fs2 = readfile(f2, outdtype="int16")
        cmp_result = compare(s1, s2, fs1, per_frame=False, test_start_offset_ms=test_offset_ms)
        cmp_result = compare(
            s1, s2, fs1, per_frame=False, test_start_offset_ms=test_offset_ms
        )
        tool_output = cmp_result["max_abs_diff"]

    with threading.Lock():
@@ -298,7 +305,7 @@ if __name__ == "__main__":
    )
    parser.add_argument(
        "--tool",
        choices=["mld", "CompAudio", "pyaudio3dtools"],
        choices=["mld", "CompAudio", "pyaudio3dtools", "ssnr"],
        default="CompAudio",
        help="Compare tool to run",
    )
@@ -306,7 +313,7 @@ if __name__ == "__main__":
        "--test_offset_ms",
        type=int,
        default=0,
            help="Offset in miliseconds that is ignored at the start of the files in folder2 (only used if tool=pyaudio3dtools)"
        help="Offset in miliseconds that is ignored at the start of the files in folder2 (only used if tool=pyaudio3dtools)",
    )
    args = parser.parse_args()