Giter Club home page Giter Club logo

timbral_models's Issues

[line 253:] segment returns a empty list when a sound file has too short attack time.

Got the following error when I tried to compute timbral_hardness for the following sound. I suspect it's because the sound has too short attack time.

http://freesound.org/people/ShawnyBoy/sounds/165394/

ERROR :
line 253, in timbral_hardness
segment /= float(max(segment))
ValueError: max() arg is an empty sequence

To confirm I tried to print the values of segment and found out one of the segments is an empty list for this sound. I tried to add a condition to ignore the block if there is an empty sequence but couldn't solve it and not quite sure how to optimise the code for this use case

Add info about requirements

Some of the scripts require external software to be installed and won't work out of the box (e.g. numpy, soundfile, librosa). These should al least be listed in the README. In future iterations it would be great to provide a docker image (we can do it as part of the main audio commons extractor) to facilitate running these algorithms.

Missing dependency on the documentation: pyfilterbank

Maybe I'm missing something, but I had to install pyfilterbank before being able to import timbral_models. Just wanted to point it out in case the documentation needs to be updated.

By the way, in order to install pyfilterbank, I just did:

  1. git clone https://github.com/SiggiGue/pyfilterbank.git
  2. cd pyfilterbank
  3. python setup.py install

all_hp_centroid instead of all_hp_centroid_tpower in Timbral_Brightness.py

Hi,
if I read the code in Timbral_Brightness.py correctly, line 125 should say:
all_hp_centroid_tpower.append(hp_centroid_tpower)
and line 132 should say:
weighted_mean_hp_centroid = np.average(all_hp_centroid, weights=all_hp_centroid_tpower)

Otherwise the hp_centroid array would contain a mixture of centroid frequencies and powers, and the average in line 129 and 132 would not make too much sense.

Is this correct? Can you fix it?
Thank you!
Giampiero and Jérôme

Deprecation of sklearn

Your https://github.com/AudioCommons/timbral_models/blob/master/setup.py depends on sklearn, which is now deprecated. The suggested fix is to use scikit-learn instead.

Does someone have the time to try this? For some reason I get an error when trying to clone the repository. The easiest way to try might be

onset_detect() takes 0 positional arguments but 2 were given.

I'm running into an error as soon as I try to run it, using the sample code given in your readme.

code:
import timbral_models

frame = r"Downloads\Ingentia60.mp3"
timbre = timbral_models.timbral_extractor(frame)

print(timbre)

error:
Calculating hardness...
Traceback (most recent call last):
File "C:\Users\andre\OneDrive\VSCode\transcribeapp\timbre.py", line 4, in
timbre = timbral_models.timbral_extractor(frame)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\timbral_models\Timbral_Extractor.py", line 70, in timbral_extractor
hardness = timbral_hardness(audio_samples, fs=fs,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\timbral_models\Timbral_Hardness.py", line 87, in timbral_hardness
original_onsets = timbral_util.calculate_onsets(audio_samples, envelope, fs, nperseg=nperseg)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\timbral_models\timbral_util.py", line 642, in calculate_onsets
onsets = librosa.onset.onset_detect(audio_samples, fs, backtrack=True, units='samples')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: onset_detect() takes 0 positional arguments but 2 positional arguments (and 2 keyword-only arguments) were given

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

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

features meaning

Are there any documents that explained how these features are calculated?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.