Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to extract only a subset of features? #107

Open
oscars47 opened this issue Jun 28, 2024 · 3 comments
Open

How to extract only a subset of features? #107

oscars47 opened this issue Jun 28, 2024 · 3 comments

Comments

@oscars47
Copy link

Hello,

My problem is I want to start with, say, the ComParE-2016 features, but instead of actually computing all 6373 of them at once, pass in a list of strings custom_feature_ls which are a subset of the full feature list, and only actually perform the computation of these specific features. I haven't seen any direct support for this in the source code, nor can I quite figure out how to specify a config file to do this. Thanks!

@maxschmitt
Copy link

The most straightforward way is to simply compute all features and select a subset in the returned DataFrame, e.g., if you want F0 mean and range:

import numpy as np
import opensmile


sampling_rate = 16000
signal = np.sin(np.arange(sampling_rate)*440*2*np.pi/sampling_rate)

smile = opensmile.Smile(
    feature_set=opensmile.FeatureSet.ComParE_2016,
    feature_level=opensmile.FeatureLevel.Functionals,
)

features = smile.process_signal(
    signal,
    sampling_rate
)

custom_feature_ls = ["F0final_sma_amean",
                     "F0final_sma_range",
                     ]

features_selected = features[custom_feature_ls]
print(features_selected)

#                         F0final_sma_amean  F0final_sma_range
# start  end                                                  
# 0 days 0 days 00:00:01         439.721619            0.03595

Adapting the config file is also possible, of course, but much more complex.

@oscars47
Copy link
Author

oscars47 commented Jul 24, 2024

Hi, thank you Max for getting back to me and including this example. Right of course we can postselect, but is there a way to preselect what components are calculated in the first place from the config file?

@maxschmitt
Copy link

Yes, you need to go through the config file and remove components/features that are not required. It is not very straightforward as you need to get familiar with the structure of the config file and as they are quite long for this particular feature set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants