audeering / opensmile-python

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

Change framesize and framestep in ComParE_2016 config file #76

Open rodaslemos opened 1 year ago

rodaslemos commented 1 year ago

Hello everyone,

I am doing my master's thesis and I want to use openSMILE to extract features from my audio files. If I use the standard configuration of ComParE_2016 with the low level descriptors

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

everything is alright. However, I would like to increase the framesize to get shorter sequences. I found here in github issue https://github.com/audeering/opensmile-python/issues/42 of someone with the same intention as me I followed the suggested steps:

After this I run the following command:

smile = opensmile.Smile( feature_set='ComParE_2016.conf', feature_level='lld', )

but I got this error : OpenSmileException: Code: 6 . Maybe the problem is in the creation of the config files: all I did was copy the files from github but I added in the first line config_str = ''' and in the last line i closed with '''. Should I save all files as .conf or with the same extensions as seen in the github? How can I solve this?

zehuiwu commented 1 year ago

Here is how I solved the problem:

  1. find the location of the opensmile-python package
  2. go to the "opensmile-python/opensmile/core/config/compare" folder
  3. open the config file ComParE_2016_core.lld.conf.inc
  4. change the frame size and frame step at lines 18-19
  5. make the same change to the frame size and frame step at lines 51-52
  6. run smile = opensmile.Smile( feature_set=opensmile.FeatureSet.ComParE_2016, feature_level=opensmile.FeatureLevel.LowLevelDescriptors, ) y = smile.process_file('audio.wav')

I hope this helps!

najdamikolaj00 commented 6 months ago

@zehuiwu Thanks, this one works, although I have a feeling it should be more straightforward.

There is a script which helps a little bit:

config_file_path = ''

new_frame_size = '0.030'  # Frame size in seconds original 0.060
new_frame_step = '0.030'   # Frame step in seconds original 0.01

with open(config_file_path, 'r') as file:
    lines = file.readlines()

lines[17] = f'frameSize={new_frame_size}\n'
lines[18] = f'frameStep={new_frame_step}\n'
lines[50] = f'frameSize={new_frame_size}\n'
lines[51] = f'frameStep={new_frame_step}\n'

with open(config_file_path, 'w') as file:
    file.writelines(lines)

print("Configuration file has been updated.")