Hi,
First of all, thanks for making binaqual openly available.
Issue
I’m encountering an IndexError: list index out of range when the input audio length is slightly longer than a multiple of 12 seconds.
File ".../Binaqual/vnsim.py", line 107, in calc_ref_test_similarity
neurogram_map = mask_patches[patch_index] * neurogram_map
~~~~~~~~~~~~^^^^^^^^^^^^^
IndexError: list index out of range
Observation
It appears that mask_patches contains fewer patches than ref_patches and test_patches, which leads to the out-of-range access.
Reproduction
I can consistently reproduce the issue using randomly generated audio whose length is just a few samples longer than an exact multiple of 12 seconds:
FS = 48000
# random integer number
N = np.random.randint(1, 20) # random multiplier of 12 seconds
remainder = np.random.randint(1, 60) # random number of remaining samples to add
print(f"N: {N}, remainder: {remainder}")
length = 12*N*FS + remainder
# Generate random stereo noise
noise_ref = np.random.randn(length, 2)
noise_test = np.random.randn(length, 2)
# Create temp files
ref_temp = tempfile.NamedTemporaryFile(suffix='.wav', delete=False)
test_temp = tempfile.NamedTemporaryFile(suffix='.wav', delete=False)
try:
sf.write(ref_temp.name, noise_ref, FS)
sf.write(test_temp.name, noise_test, FS)
nsim_values, LS = calculate_binaqual(
Path(ref_temp.name),
Path(test_temp.name),
intensity_threshold=-180,
elc=0,
ignore_freq_bands=0
)
print(f"NSIM values: {nsim_values}")
print(f"LS: {LS}")
finally:
ref_temp.close()
test_temp.close()
os.unlink(ref_temp.name)
os.unlink(test_temp.name)
I hope this issue report helps!
Hi,
First of all, thanks for making binaqual openly available.
Issue
I’m encountering an IndexError: list index out of range when the input audio length is slightly longer than a multiple of 12 seconds.
Observation
It appears that mask_patches contains fewer patches than ref_patches and test_patches, which leads to the out-of-range access.
Reproduction
I can consistently reproduce the issue using randomly generated audio whose length is just a few samples longer than an exact multiple of 12 seconds:
I hope this issue report helps!