Skip to content

Commit

Permalink
Merge pull request #248 from claritychallenge/105-inconsistent-logic-…
Browse files Browse the repository at this point in the history
…with-parameter-shift-in-evaluatorhaspiebcenterfreq

closes #105
  • Loading branch information
jonbarker68 committed Mar 24, 2023
2 parents bfc3d20 + ee27af3 commit 16e0472
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 4 additions & 8 deletions clarity/evaluator/haspi/eb.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def ear_model(
level1,
nchan=32,
m_delay=1,
shift=0.02,
shift=None,
):
"""
Function that implements a cochlear model that includes the middle ear,
Expand Down Expand Up @@ -117,11 +117,10 @@ def ear_model(

# Parameters for the control filter bank
hl_max = [100, 100, 100, 100, 100, 100]
_center_freq_control = center_frequency(
nchan, shift
) # Center frequencies for the control
_, bandwidth_1, _, _, _ = loss_parameters(hl_max, _center_freq_control)
# Compute center frequencies for the control
_center_freq_control = center_frequency(nchan, shift)
# Maximum BW for the control
_, bandwidth_1, _, _, _ = loss_parameters(hl_max, _center_freq_control)

# Input signal adjustments
# Convert the signals to 24 kHz sampling rate.
Expand Down Expand Up @@ -357,9 +356,6 @@ def center_frequency(
Translated from MATLAB to Python by Zuzanna Podwinska, March 2022.
"""

# In the Matlab code, the loop below never evaluates
# (but the current code was trained with this bug)
shift = None # This is to keep consistency with MATLAB code
if shift is not None:
k = 1
A = 165.4 # pylint: disable=invalid-name
Expand Down
9 changes: 9 additions & 0 deletions clarity/evaluator/haspi/haspi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def haspi_v2( # pylint: disable=too-many-arguments too-many-locals
version of HASPI uses a modulation filterbank followed by an ensemble of
neural networks to compute the estimated intelligibility.
**NB** - The original HASPI model derivation included a bug which meant that
although the 'shift' parameter used in band centre frequency calculations was set to
'0.02' it was never actually applied. To replicate this behaviour ear_model is
called with 'shift' set to None. For discussion please refer to the discussion in
`Issue #105 <https://github.com/claritychallenge/clarity/issues/105>`
for further details.
Args:
reference (np.ndarray): Clear input reference speech signal with no noise or
distortion. If a hearing loss is specified, no amplification should be
Expand Down Expand Up @@ -68,6 +75,8 @@ def haspi_v2( # pylint: disable=too-many-arguments too-many-locals
hearing_loss,
itype,
level1,
# shift=0.02 # See comment in docstring
shift=None,
)

# Envelope modulation features
Expand Down

0 comments on commit 16e0472

Please sign in to comment.