audiocommons / timbral_models Goto Github PK
View Code? Open in Web Editor NEWPython scripts for modelling timbral attributes
License: Apache License 2.0
Python scripts for modelling timbral attributes
License: Apache License 2.0
The error occurs when there is a zero in the array :
spec[WR_upper_f_limit_idx:]
a working fix is replacing the line 217 with :
above_WR_spec = [value if value == 0 else np.log10(value) for value in spec[WR_upper_f_limit_idx:]]
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
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.
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:
git clone https://github.com/SiggiGue/pyfilterbank.git
cd pyfilterbank
python setup.py install
Can't install package because sklearn is deprecated.
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
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
cd your/path/to/timbral_models
and try to locally install using pip install -e .
(you might want to do this in a separate python environment)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
This line:
makes the Timbral_Depth model to fail. I guess it should simply be removed as there is already a line before for loading a file and this might come from old code.
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
Are there any documents that explained how these features are calculated?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.