tyiannak / pyAudioAnalysis

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

Audio segmentation, mt_file_classification: IndexError #355

Open VivT94 opened 3 years ago

VivT94 commented 3 years ago

Hi, while working on a project for university, we came across pyAudioAnalysis. Our goal is to classify noises during nighttime into either "snoring" or "no snoring". I trained a svm classifier with a few sample audio files and afterwards applied the functions "silence removal" and "mid_term_file_classification" - see code below:

from pyAudioAnalysis import audioBasicIO as aIO from pyAudioAnalysis import audioSegmentation as aS

[Fs, x] = aIO.read_audio_file("../data/training_data/mixed/soundsample.wav") segments = aS.silence_removal(x, Fs, 0.020, 0.020, smooth_window = 1.0, weight = 0.3, plot = True)

[flagsInd, classesAll, acc, CM] = aS.mid_term_file_classification("../data/training_data/mixed/soundsample.wav", "svm_NoSnoring_Snoring", "svm", True, '../data/training_data/mixed/soundsample.segments')

The silence removal works totally fine, but unfortunately, the "mid_term_file_classification" gives this IndexError: "File "C:\Users.......\pyAudioAnalysis\audioSegmentation.py", line 115, in segments_to_labels while index < end_times[-1]: IndexError: index -1 is out of bounds for axis 0 with size 0"

Can anyone help? Also, I created an empty .segments-file before running this code, but it remains empty.

Thanks in advance!