felixbur / nkululeko

Machine learning speaker characteristics
MIT License
26 stars 4 forks source link

Error on `praat` features with file checker #68

Closed bagustris closed 7 months ago

bagustris commented 10 months ago

Even though already using check_size for file checker, I still got the following error on using praat features. The error did not show when I changed the feature to os.

DEBUG nkululeko: running results/exp_asvp_praat from config data/asvp-esd/exp.ini, nkululeko version 0.64.0
DEBUG dataset: loading train
DEBUG dataset: value for audio_path not found, using default: 
DEBUG dataset: Loaded database train with 10100 samples: got targets: True, got speakers: False, got sexes: False
DEBUG dataset: train: loaded data with 10100 samples: got targets: True, got speakers: False, got sexes: False
DEBUG dataset: loading test
DEBUG dataset: value for audio_path not found, using default: 
DEBUG dataset: Loaded database test with 2525 samples: got targets: True, got speakers: False, got sexes: False
DEBUG dataset: test: loaded data with 2525 samples: got targets: True, got speakers: False, got sexes: False
DEBUG experiment: loaded databases train,test
DEBUG dataset: splitting database train with strategy train
DEBUG dataset: train: 0 samples in test and 10100 samples in train
DEBUG dataset: value for strategy not found, using default: train_test
DEBUG experiment: warn: train test empty
DEBUG dataset: splitting database test with strategy test
DEBUG dataset: test: 2525 samples in test and 0 samples in train
DEBUG dataset: value for strategy not found, using default: train_test
DEBUG experiment: warn: test train empty
DEBUG filechecker: : checked for samples less than 1000 bytes, reduced samples from 8786 to 8786
DEBUG filechecker: : checked for samples less than 1000 bytes, reduced samples from 2214 to 2214
DEBUG experiment: value for filter.sample_selection not found, using default: all
DEBUG experiment: value for type not found, using default: dummy
DEBUG experiment: Categories test: ['pain' 'happy' 'fear' 'excited' 'neutral' 'surprise' 'sad' 'disgust'
 'pleasure' 'disapointed' 'boredom']
DEBUG experiment: Categories train: ['happy' 'boredom' 'neutral' 'sad' 'surprise' 'disgust' 'pain' 'excited'
 'fear' 'disapointed' 'pleasure']
DEBUG nkululeko: train shape : (8786, 4), test shape:(2214, 4)
DEBUG featureset: value for store_format not found, using default: pkl
DEBUG featureset: extracting Praat features, this might take a while...
praat: extracting file 0 of 8786
praat: extracting file 10 of 8786
praat: extracting file 20 of 8786
praat: extracting file 30 of 8786
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/bagus/github/nkululeko/nkululeko/nkululeko.py", line 58, in <module>
    main(cwd) # use this if you want to state the config file path on command line
  File "/home/bagus/github/nkululeko/nkululeko/nkululeko.py", line 46, in main
    expr.extract_feats()
  File "/home/bagus/github/nkululeko/nkululeko/experiment.py", line 334, in extract_feats
    self.feats_train =self.feature_extractor.extract()
  File "/home/bagus/github/nkululeko/nkululeko/feature_extractor.py", line 135, in extract
    self.featExtractor.extract()
  File "/home/bagus/github/nkululeko/nkululeko/feat_extract/feats_praat.py", line 28, in extract
    self.df = feinberg_praat.compute_features(self.data_df.index)
  File "/home/bagus/github/nkululeko/nkululeko/feat_extract/feinberg_praat.py", line 172, in compute_features
    (f1_mean, f2_mean, f3_mean, f4_mean, f1_median, f2_median, f3_median, f4_median) = measureFormants(
  File "/home/bagus/github/nkululeko/nkululeko/feat_extract/feinberg_praat.py", line 86, in measureFormants
    f1_mean = statistics.mean(f1_list)
  File "/usr/lib/python3.8/statistics.py", line 315, in mean
    raise StatisticsError('mean requires at least one data point')
statistics.StatisticsError: mean requires at least one data point

This could be related to how the features inside Praat are calculated. An example is with ASVP-ESD dataset with the following INI file.

[EXP]
root = ./
name = results/exp_asvp_os
save = True
[DATA]
databases = ['train', 'test']
train = ./data/asvp-esd/asvp_train.csv
train.type = csv
train.absolute_path = False
train.split_strategy = train
test = ./data/asvp-esd/asvp_test.csv
test.type = csv
test.absolute_path = False
test.split_strategy = test
target = emotion
; no_reuse = True
labels =["boredom","neutral","happy", "sad","angry", "fear", "disgust", "surprise", "excited","pleasure","pain","disapointed"]
check_size = 1000
; min_duration_of_samples = 1
[FEATS]
type = ['praat']
; scale = standard
[MODEL]
type = svm
felixbur commented 9 months ago

I guess it would really help if nkululeko would output the exact name of the audio file that caused the error. I'll try to add that

felixbur commented 9 months ago

can you send a wav file that causes the error?

bagustris commented 9 months ago

I used asvp-esd dataset,

https://zenodo.org/records/7132783

Instructions are available in data/asvp-esd.

felixbur commented 8 months ago

Please try again with version 0.68.1

bagustris commented 8 months ago

Now it gives information on which files are causing errors. Here the output with INI file above.

...
100%|██████████████████████████████████████▉| 8780/8786 [32:28<00:01,  4.17it/s]error on file ././data/asvp-esd//ASVP-ESD-Update/Audio/actor_99/03-02-02-01-03-99-02-02-02-02.wav: mean requires at least one data point
100%|███████████████████████████████████████| 8786/8786 [32:29<00:00,  4.51it/s]

Warning: 3870 Nans in x, replacing with 0
Warning: 96646 infinite in x
Now extracting speech rate parameters...
  0%|                                          | 8/8786 [00:00<01:58, 74.39it/s]caught zero division
caught zero division
caught zero division
  0%|                                         | 20/8786 [00:00<01:30, 96.50it/s]/home/bagus/github/nkululeko/nkululeko/feat_extract/feinberg_praat.py:514: PraatWarning: The loudest and softest part in your sound differ by only 9.009522902670497 dB.
  textgrid = call(
caught zero division
  0%|▏                                        | 30/8786 [00:00<02:10, 67.15it/s]
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/bagus/github/nkululeko/nkululeko/nkululeko.py", line 72, in <module>
    main(
  File "/home/bagus/github/nkululeko/nkululeko/nkululeko.py", line 57, in main
    expr.extract_feats()
  File "/home/bagus/github/nkululeko/nkululeko/experiment.py", line 344, in extract_feats
    self.feats_train = self.feature_extractor.extract()
  File "/home/bagus/github/nkululeko/nkululeko/feature_extractor.py", line 164, in extract
    self.featExtractor.extract()
  File "/home/bagus/github/nkululeko/nkululeko/feat_extract/feats_praat.py", line 34, in extract
    self.df = feinberg_praat.compute_features(self.data_df.index)
  File "/home/bagus/github/nkululeko/nkululeko/feat_extract/feinberg_praat.py", line 453, in compute_features
    df_speechrate = get_speech_rate(file_index)
  File "/home/bagus/github/nkululeko/nkululeko/feat_extract/feinberg_praat.py", line 485, in get_speech_rate
    speechrate_dictionary = speech_rate(sound)
  File "/home/bagus/github/nkululeko/nkululeko/feat_extract/feinberg_praat.py", line 567, in speech_rate
    currenttime = timepeaks[0]
IndexError: list index out of range
felixbur commented 8 months ago

please try again with version 0.68.3

bagustris commented 8 months ago

It now works with the outputs below.

...
DEBUG feature_extractor: praat: shape : (2214, 39)
DEBUG experiment: All features: train shape : (8786, 39), test shape:(2214, 39)
DEBUG experiment: scaler: False
DEBUG runmanager: value for runs not found, using default: 1
DEBUG runmanager: run 0
DEBUG model: value for C_val not found, using default: 0.001
DEBUG modelrunner: value for epochs not found, using default: 1
DEBUG modelrunner: run: 0 epoch: 0: result: test: 0.266 UAR
DEBUG modelrunner: plotting confusion matrix to train_test_svm_praat__0_000_cnf
DEBUG reporter: result per class (F1 score): [0.0, 0.0, 0.119, 0.047, 0.627, 0.394, 0.4, 0.223, 0.0, 0.468, 0.421]
DEBUG experiment: Done, used 51.386 seconds
DONE
felixbur commented 8 months ago

it seems many files have problems with this dataset