From 00d29ca873e46276a05fdabb62c13bf2226f950a Mon Sep 17 00:00:00 2001 From: Gerardo Roa Dabike Date: Tue, 15 Nov 2022 12:18:52 +0000 Subject: [PATCH] Adding exceptions for hl and cfs Signed-off-by: Gerardo Roa Dabike --- clarity/enhancer/nalr.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clarity/enhancer/nalr.py b/clarity/enhancer/nalr.py index 46e53c844..c97e8d514 100644 --- a/clarity/enhancer/nalr.py +++ b/clarity/enhancer/nalr.py @@ -131,8 +131,12 @@ def __init__(self, nfir: int, fs: int): self.delay[nfir // 2] = 1.0 def hl_interp(self, hl: np.ndarray, cfs: np.ndarray): - assert len(hl) == len(cfs), "Hearing losses and center frequencies don't match!" - hl_interpf = scipy.interpolate.interp1d(cfs, hl) + try: + hl_interpf = scipy.interpolate.interp1d(cfs, hl) + except ValueError: + raise ValueError( + "Hearing losses (hl) and center frequencies (cfs) don't match!" + ) return hl_interpf(self.aud) def build(