tyiannak / pyAudioAnalysis

Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications
Apache License 2.0
5.83k stars 1.19k forks source link

Mismatch between wiki and program functionality in "Feature extraction - storing to file" #318

Closed slowglow closed 3 years ago

slowglow commented 4 years ago

The wiki section "Feature extraction - storing to file for a sequence of WAV files stored in a given path" gives the following command and explains that the output should be in four feature files (2 CSVs and 2 NUMPY), one pair for short-term features and one pair for mid-term features:

python3 audioAnalysis.py featureExtractionDir -i data/ -mw 1.0 -ms 1.0 -sw 0.050 -ss 0.050

The result of the command on my machine is that it produces only two short-term files, not the four, as described in the wiki. After some digging around, it seems that the command line call is sent to:

-> audioAnalysis.featureExtractionDir -> MidTermFeatures.mid_feature_extraction_file_dir -> MidTermFeatures.mid_feature_extraction_to_file

mid_feature_extraction_to_file executes one of two branches and saves only one pair of files - short or mid-term, depending on the input parameters. Because the inputs store_short_features=False, store_csv=False, plot=False are hardcoded as (True, True, True) in audioAnalysis.featureExtractionDir the first branch of mid_feature_extraction_to_file which writes the short-term files is always executed. Conversely, the second branch of mid_feature_extraction_to_file, which is supposed to write the mid-term files never executes.

It seems, that during code refactoring, there was intent to change the behavior of the mid_feature_extraction_to_file depending on the input conditions, but the change was carried only halfway.

I am seeing this with the latest master. Can we have this fixed?

slowglow commented 3 years ago

I can help fixing this in the code or help re-writing the wiki, if I knew what was the authors' intention. For me, personally, the wiki description makes more sense and branching the code is unnecessary - just output both short- and mid-term feature files if output is requested in the call to MidTermFeatures.mid_feature_extraction_to_file. Or don't if it isn't... Can you, please, give some clarification?

tyiannak commented 3 years ago

fixed in https://github.com/tyiannak/pyAudioAnalysis/commit/fc11a6cad7347502766b9d14e018daaa9327a4cb now all 4 files are written (2 for mid-term and 2 for short-term feature matrices)