audeering / opensmile-python

Python package for openSMILE
https://audeering.github.io/opensmile-python/
Other
240 stars 32 forks source link

Is it possible to extract frame-wise features with the parameter "options"? #14

Open 00001101-xt opened 3 years ago

00001101-xt commented 3 years ago

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

The above script gives me features with shape 1x88, but I want frame-wise features with shape Nx88, so I changed the above statement to:

smile = opensmile.Smile(feature_set=opensmile.FeatureSet.eGeMAPSv01b, feature_level=opensmile.FeatureLevel.Functionals, options={"frameMode": "fixed", "frameSize": 0.025, "frameStep": 0.010})

But it produces 1x88 features still, so I wonder is it possible to extract Nx88 features setting the options parameter?

Thanks in advance.

frankenjoe commented 3 years ago

You can use feature_level=opensmile.LowLevelDescriptors, which will extract low-level descriptors instead of functionals. For opensmile.FeatureSet.eGeMAPSv01b you will get Nx10 features.

If your goal is to extract functionals on a running window, you can use the arguments starts and ends of process_files or start and end of process_signal. However, you should use a larger window size than 0.025 in this case.

krishna51119 commented 3 years ago

@frankenjoe Can I exctract standalone features like MFCC etc using this script?

frankenjoe commented 3 years ago

We have scripts that extract MFCCs only: https://github.com/audeering/opensmile/tree/master/config/mfcc

Note that you have to adapt them slightly to use with pyopensmile, see https://audeering.github.io/opensmile-python/usage.html#custom-config

twoertwein commented 1 month ago

Probably not recommended but you can simply make those parameters configurable by patching FrameModeFunctionals.conf.inc:

# patch opensmile to expose configuration open
file = Path(opensmile.__path__[0]) / "core/config/shared/FrameModeFunctionals.conf.inc"
config_old = file.read_text()
config_new = (
    config_old.replace(
        "frameMode = full", "frameMode = \\cm[frameMode{full}:frameMode]"
    )
    .replace("frameSize = 0", "frameSize = \\cm[frameSize{0}:frameSize]")
    .replace("frameStep = 0", "frameStep = \\cm[frameStep{0}:frameStep]")
    .replace(
        "frameCenterSpecial = left",
        "frameCenterSpecial = \\cm[frameCenterSpecial{left}:frameCenterSpecial]",
    )
)
if config_new != config_old:
    file.write_text(config_new)