clarity.enhancer.gha.gha_utils module¶
- class clarity.enhancer.gha.gha_utils.FittingParams[source]¶
Bases:
TypedDict
Fitting parameters for gaintable calculation.
- channels: int¶
- edge_frequencies: ndarray¶
- frequencies: ndarray¶
- levels: ndarray¶
- side: str¶
- class clarity.enhancer.gha.gha_utils.Gaintable[source]¶
Bases:
TypedDict
Gaintable for a given audiogram.
- channels: int¶
- frequencies: ndarray¶
- levels: ndarray¶
- noisegatelevel: ndarray¶
- noisegateslope: ndarray¶
- sGt: ndarray¶
- sGt_uncorr: ndarray¶
- clarity.enhancer.gha.gha_utils.format_gaintable(gaintable: Gaintable, noisegate_corr: bool = True) str [source]¶
Format gaintable for insertion into cfg file as long string.
- Parameters:
gaintable (ndarray) – The gaintable to format
noisegate_corr (boolean, optional) – apply noisegate correction or do not (default: True)
- Returns:
- gaintable formatted for insertion into OpenMHA
cfg file
- Return type:
str
- clarity.enhancer.gha.gha_utils.get_gaintable(audiogram_left: Audiogram, audiogram_right: Audiogram, noisegate_levels: float | ndarray, noisegate_slope: float | ndarray, cr_level: float, max_output_level: float) Gaintable [source]¶
Compute a gaintable for a given audiogram.
Replaces MATLAB GUI interface of original OpenMHA software for gaintable_camfit_compr table calculation. Assumes two channels and that audiogram frequencies are identical at two ears.
- Parameters:
audiogram_left (Audiogram) – the audiogram for the left ear
audiogram_right (Audiogram) – the audiogram for the right ear
audf (list) – audiogram frequencies for fitting
noisegatelevels (ndarray) – compression threshold levels for each frequency band
noisegateslope (float) – determines slope of gains below compression threshold
cr_level (int) – overall input level in dB for calculation of compression ratios
max_output_level (int) – maximum output level in dB
- Returns:
dim ndarray of gains
- Return type:
dict
- clarity.enhancer.gha.gha_utils.multifit_apply_noisegate(gain_table: ndarray, sFit_model_frequencies: ndarray, sFit_model_levels: ndarray, noisegate_level: ndarray, noisegate_slope: ndarray) ndarray [source]¶
Apply noisegate to the gain table
Based on OpenMHA subfunction of libmultifit.m.
- Parameters:
gain_table (ndarray) – gain array
sFit_model_frequencies (list) – FFT filterbank frequencies
sFit_model_levels (ndarray) – levels at which to calculate gains
noisegate_level (ndarray) – chosen compression threshold
noisegate_slope (ndarray) – determines slope below compression threshold
- Returns:
gain table with noisegate applied
- Return type:
ndarray