pyAudioAnalysis icon indicating copy to clipboard operation
pyAudioAnalysis copied to clipboard

How do I get segment data from audio file?

Open cnbeining opened this issue 9 years ago • 12 comments

Hi,

Thanks for writing this module.

I am a little bit confused with audioSegmentation.py about getting raw segment data(i.e., stuffs like

0.01,9.90,speech
9.90,10.70,silence
10.70,23.50,speech

) from the audio file.

Which function should I use to get such data(in any form of data type)?

Many thanks.

cnbeining avatar Sep 12 '16 17:09 cnbeining

Hi Check out the audio segmentation wiki. The quick answer is that u should use mtFileClassification().

tyiannak avatar Oct 25 '16 20:10 tyiannak

Why don't you use simple indexing?

Given sample rate Fs.

audio[(0.01_Fs): (9.90_Fs)-1]

cksajil avatar Nov 12 '16 17:11 cksajil

Hi! I am also looking into this.

In the wiki it says that .segments files can be used for performance evaluation. However, I am looking to generate a .segments file from running segmentation on a .wav file. How should this be done?

Thanks

simonnarang avatar Jan 16 '17 19:01 simonnarang

Hi,

I have same question and still wondering to find out how to generate the .segments file! Any one was able to do that?

Thanks-

samah0 avatar Feb 15 '17 00:02 samah0

Hi,

I am getting this error while trying to compile the example code from the wiki

from pyAudioAnalysis import audioSegmentation as aS
[flagsInd, classesAll, acc, CM] = aS.mtFileClassification("data/scottish.wav", "data/svmSM", "svm", True, 'data/scottish.segments')

mtFileClassificationError: input modelType not found!
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-bd6617b411ea> in <module>()
----> 1 [flagsInd, classesAll, acc, CM] = aS.mtFileClassification(audioLocation, "data/svmSM", "svm", True, 'data/scottish.segments')

ValueError: need more than 3 values to unpack

ThomasLengeling avatar Feb 28 '17 22:02 ThomasLengeling

I have same question and still wondering to find out how to generate the .segments file! Any one was able to do that?when I use my own chinese datasets.

zhengqun avatar Nov 21 '18 03:11 zhengqun

$python audioAnalysis.py speakerDiarization -i ../your/data/file/dic/test.wav --num 0 --flsd

and just in case you wanna generate segmented wav file, add the following after line 943 in audioSegmentation.py:

(segs, classes) = flags2segs(cls, mt_step)

for i,s in enumerate(segs):
    person = int(classes[i]) + 1 
    person = chr(97+person)
    strout = "{0:s}_{3:s}_{1:.3f}_{2:.3f}_.wav".format(filename[:-4],s[0],s[1],person)
    scipy.io.wavfile.write(strout, fs , x[int(fs * s[0]) : int(fs * s[1])] )

jardnzm avatar May 28 '19 13:05 jardnzm

the same problem:

from pyAudioAnalysis import audioSegmentation as aS [flagsInd, classesAll, acc, CM] = aS.mid_term_file_classification("data/scottish.wav", "/data/models/svm_rbf_sm", "svm", True, 'data/scottish.segments') mtFileClassificationError: input model_type not found!

maggie0830 avatar Apr 16 '20 06:04 maggie0830

the same problem:

from pyAudioAnalysis import audioSegmentation as aS [flagsInd, classesAll, acc, CM] = aS.mid_term_file_classification("data/scottish.wav", "/data/models/svm_rbf_sm", "svm", True, 'data/scottish.segments') mtFileClassificationError: input model_type not found!

Model path seems wrong ("/" is not correct before data)

tyiannak avatar Apr 16 '20 19:04 tyiannak

I don't have any data folder in pyAudioAnalysis. How to get the model type (data/svmSM)? Please help me. It is showing: mtFileClassificationError: input model_type not found! aS.mid_term_file_classification(file name,"what to write here?","svm")

pratsat18 avatar Apr 25 '20 11:04 pratsat18

the same problem:

from pyAudioAnalysis import audioSegmentation as aS [flagsInd, classesAll, acc, CM] = aS.mid_term_file_classification("data/scottish.wav", "/data/models/svm_rbf_sm", "svm", True, 'data/scottish.segments') mtFileClassificationError: input model_type not found!

Model path seems wrong ("/" is not correct before data)

segments = aS.mid_term_file_classification(audio_filepath, "data/models/svm_rbf_sm", "svm", True) i tired using without slash . but getting the same error, mtFileClassificationError: input model_type not found!

i can see the models from data folder , is any other way , we can add those path?

prabhakaran02 avatar May 23 '20 06:05 prabhakaran02

What worked for me was to add the absolute path (in Windows):

data_path = "C:/path/to/the/package/pyAudioAnalysis/pyAudioAnalysis/" [flagsInd, classesAll, acc, CM] = aS.mid_term_file_classification(data_path + "data/scottish.wav", data_path + "data/models/svm_rbf_sm", "svm", True, data_path + 'data/scottish.segments')

My working directory was in another folder, so it couldn't find the files.

Zeboku avatar Sep 05 '22 22:09 Zeboku