Skip to content

slice indices must be integers or None or have an __index__ method [in timbral_brightness and timbral_hardness] #5

@ffont

Description

@ffont

When processing this sound: https://freesound.org/people/bone666138/sounds/198841/ both timbral_brightness and timbral_hardness models fail (the others work fine). Both return the same error, although it happens in different parts of the code and might be completely unrelated. This is the Python stack trace for the errors:

timbral_brightness

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-85-852004113145> in <module>()
----> 1 timbral_brightness('/mtgdb/incoming/freesound/sounds/198/198841_285997.wav')

~/freesound-audio-analyzer/timbral_models/Timbral_Brightness.py in timbral_brightness(fname)
    105         eval_audio = audio_samples[i:i + blockSize]
    106         complex_spectrum = np.fft.fft(eval_audio * window)
--> 107         magnitude_spectrum = np.absolute(complex_spectrum[0:1 + len(complex_spectrum) / 2])
    108 
    109         if sum(magnitude_spectrum) > 0:

TypeError: slice indices must be integers or None or have an __index__ method

timbral_hardness

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-86-d8f62a7fc6e0> in <module>()
----> 1 timbral_hardness('/mtgdb/incoming/freesound/sounds/198/198841_285997.wav')

~/freesound-audio-analyzer/timbral_models/Timbral_Hardness.py in timbral_hardness(fname, dev_output, max_attack_time, bandwidth_thresh_db, phase_correction)
    636 
    637     # calculate the onsets
--> 638     original_onsets = calculate_onsets(audio_samples, envelope, fs, nperseg=nperseg)
    639     onset_strength = librosa.onset.onset_strength(audio_samples, fs)
    640 

~/freesound-audio-analyzer/timbral_models/Timbral_Hardness.py in calculate_onsets(audio_samples, envelope_samples, fs, look_back_time, hysteresis_time, hysteresis_percent, onset_in_noise_threshold, threshold_correction, minimum_onset_time_separation, nperseg)
    507             current_strength_onset = strength_onset_times[onset_idx]
    508             if current_strength_onset == strength_onset_times[-1]:
--> 509                 onset_strength_seg = onset_strength[current_strength_onset:]
    510             else:
    511                 onset_strength_seg = onset_strength[current_strength_onset:strength_onset_times[onset_idx + 1]]

TypeError: slice indices must be integers or None or have an __index__ method

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions