MTG / essentia

C++ library for audio and music analysis, description and synthesis, including Python bindings
http://essentia.upf.edu
GNU Affero General Public License v3.0
2.85k stars 533 forks source link

question: python example for gaiatransform #576

Open SimonF89 opened 7 years ago

SimonF89 commented 7 years ago

Hi, could you post a example for the gaiatransform in python? Iam running crazy... I want to extract these features:

musical genre (4 different databases)
ballroom music classification
moods: happy, sad, aggressive, relaxed, acoustic, electronic, party
western / non-western music
tonal / atonal
danceability
voice / instrumental
gender (male / female singer)
timbre classification

may you help me with this problem and maybe post a short example? Thx!!! =)

dbogdanov commented 7 years ago

From your previous comments I understand that you are interested in "real-time" classification on the input buffer. GaiaTransform relies on pre-trained models and you can train your own models using scripts in Gaia. However, the easiest solution is to use our pre-trained classifier models. To use them it is necessary to compute the same descriptors as MusicExtractor computes and then apply GaiaTransform. The MusicExtractor is not well suited for your purpose as it requires an input audio file.

We are in the process of refactoring MusicExtractor in music_extractor_refactor branch. It is now possible to run MusicExtractor as an algorithm in python, but we still have to re-train our classifier models because of some updates we did for some of the music descriptors.

In your case, as a workaround and if speed is not an issue, you could store input buffers to a file in real time and then run the command-line version of the MusicExtractor using os.system call in python. This way you will be able to re-use our old pre-trained models.

To build command line music extractor (assuming you are on linux):

highlevel:
    compute: 1
    svm_models: ['svm_models/genre_tzanetakis.history', 'svm_models/mood_sad.history']

Now you can run command-line extractor like this (and you can do that from python using os.system call): /usr/local/bin/essentia_streaming_extractor_music foo.wav foo.sig profile

We will consider modifications to MusicExtractor to allow computation from any audio input, not limited to an audio file. However, keep in mind that many of our classifier models were trained on complete audio tracks, others on 30 second fragments, and we are unaware of how robust they are for shorter audio fragments.

SimonF89 commented 7 years ago

Awesome! Thx a lot! =)

Iam looking forward to use the modified MusicExtractor in the future, but for now this workaround will work!

Thank you =)

At least, one last question: Could you write a short example of the usage of gaiatransform in python? I would like to train some Classifiers on my one and execute them in my code. I didnt found any examples and wasnt able to get it working on my own...

Thank you a lot for your quick help! =)