HMM-based segmentation & classification

Hidden Markov Models requires pre-trained transition and pre-trained prior matrices.

Function trainHMM_fromFile() is used to to train a HMM model for segmentation-classification using single annotated audio file.

Function trainHMM_fromDir() is used to train HMM model for segmentation-classification using a list of annotated files (.segments extension) stored in particular folder.

After the model is trained, function hmmSegmentation() can be used to estimate the most probable sequences of class labels, given a respective sequence of mid-term feature vectors.

Function hmmSegmentation() uses plotSegmentationResults() to plot results and evaluate the performance similar to Fixed-segment Segmentation & Classification method.

Code Example:\colon

from pyAudioAnalysis import audioSegmentation as aS
aS.trainHMM_fromFile('radioFinal/train/bbc4A.wav', 'radioFinal/train/bbc4A.segments', 'hmmTemp1', 1.0, 1.0) # train using a single file
aS.trainHMM_fromDir('radioFinal/small/', 'hmmTemp2', 1.0, 1.0) # train using a set of files in a folder
aS.hmmSegmentation('data/scottish.wav', 'hmmTemp1', True, 'data/scottish.segments') # test 1
aS.hmmSegmentation('data/scottish.wav', 'hmmTemp2', True, 'data/scottish.segments') # test 2

Command-line usage example:\colon

python audioAnalysis.py trainHMMsegmenter_fromfile -i data/count.wav --ground data/count.segments -o hmmcount -mw 0.1 -ms 0.1 (train)
python audioAnalysis.py segmentClassifyFileHMM -i data/count2.wav --hmm hmmcount (test)

model file hmmRadioSM contain a trained HMM model for speech-music discrimation. Enable it by adding -hmm hmmRadioSM to arguments.

Function evaluateSegmentationClassificationDir() evaluates the performance of either a fixed-sized method or an HMM model regarding to segmentation-classification task.

缺Example更詳細說明如何使用

Command-line syntax:\colon

python audioAnalysis.py segmentationEvaluation --model <method(svm, knn, or hmm)> --modelName <modelName> -i <directoryName>

Execution examples:\colon

(case 1) python audioAnalysis.py segmentationEvaluation --model svm --modelName data/svmSM -i radioFinal/test/
(case 2) python audioAnalysis.py segmentationEvaluation --model knn --modelName data/knnSM -i radioFinal/test/
(case 3) python audioAnalysis.py segmentationEvaluation --model hmm --modelName data/hmmRadioSM -i radioFinal/test/

For the first two cases, the fixed-sized segmentation approach is used, while for the third case the HMM approach is evaluated. In any case, the third arguments must be the folder where the audio files and annotations for evaluation are stored.

The result of these commands is the average segmentation-classification accuracy, along with the respective accuracies on each individual file of the provided folder.

1,2,3,4 各一個state, context 一個state,去分段。

results matching ""

    No results matching ""