diff --git a/ivas_processing_scripts/audiotools/wrappers/bs1770.py b/ivas_processing_scripts/audiotools/wrappers/bs1770.py index fe756c07d90a4f6f971bcf72472a5a05b3f379e1..7321b02d2537a1070386c3b18a80816cccb9ac81 100755 --- a/ivas_processing_scripts/audiotools/wrappers/bs1770.py +++ b/ivas_processing_scripts/audiotools/wrappers/bs1770.py @@ -32,6 +32,7 @@ import copy import logging +import re from pathlib import Path from tempfile import TemporaryDirectory from typing import Optional, Tuple, Union @@ -134,8 +135,13 @@ def bs1770demo( result = run(cmd, logger=logger) # parse output - measured_loudness = float(result.stdout.splitlines()[3].split(":")[1]) - scale_factor = float(result.stdout.splitlines()[-3].split(":")[1]) + # we are looking for the (floating-point) number after the search string - '( )' around the number denotes the first group + measured_loudness = float( + re.search(r"Input level:\s+([-+]?(?:\d*\.*\d+))", result.stdout).group(1) + ) + scale_factor = float( + re.search(r"Scaling factor:\s+([-+]?(?:\d*\.*\d+))", result.stdout).group(1) + ) return measured_loudness, scale_factor