def _get_max_length_feature( audio_feature_dict, sampling_rate_in_hz, audio_length_limit_in_s ): feature_type = audio_feature_dict['type'] audio_length_limit_in_samp = ( audio_length_limit_in_s * sampling_rate_in_hz ) if not audio_length_limit_in_samp.is_integer(): raise ValueError( 'Audio_file_length_limit has to be chosen ' 'so that {} (in s) * {} (sampling rate in Hz) ' 'is an integer.'.format( audio_length_limit_in_s, sampling_rate_in_hz)) audio_length_limit_in_samp = int(audio_length_limit_in_samp) if feature_type == 'raw': return audio_length_limit_in_samp elif feature_type in ['stft', 'stft_phase', 'group_delay', 'fbank']: window_length_in_s = audio_feature_dict['window_length_in_s'] window_shift_in_s = audio_feature_dict['window_shift_in_s'] return get_max_length_stft_based(audio_length_limit_in_samp, window_length_in_s, window_shift_in_s, sampling_rate_in_hz) else: raise ValueError('{} is not recognized.'.format(feature_type))
def _get_max_length_feature(audio_feature_dict, sampling_rate_in_hz, audio_length_limit_in_s): feature_type = audio_feature_dict[TYPE] audio_length_limit_in_samp = audio_length_limit_in_s * sampling_rate_in_hz if not audio_length_limit_in_samp.is_integer(): raise ValueError( "Audio_file_length_limit has to be chosen " "so that {} (in s) * {} (sampling rate in Hz) " "is an integer.".format(audio_length_limit_in_s, sampling_rate_in_hz) ) audio_length_limit_in_samp = int(audio_length_limit_in_samp) if feature_type == "raw": return audio_length_limit_in_samp elif feature_type in ["stft", "stft_phase", "group_delay", "fbank"]: window_length_in_s = audio_feature_dict["window_length_in_s"] window_shift_in_s = audio_feature_dict["window_shift_in_s"] return get_max_length_stft_based( audio_length_limit_in_samp, window_length_in_s, window_shift_in_s, sampling_rate_in_hz ) else: raise ValueError(f"{feature_type} is not recognized.")