필터 지우기
필터 지우기

How to apply pca to audio files (pitch features)?

조회 수: 10 (최근 30일)
W.Khan
W.Khan 2019년 11월 6일
댓글: Walter Roberson 2019년 11월 20일
Hello,
I applied pitch feature extraction to audio files. Now I want to apply PCA (for dimensionality reduction) to the pitch features. How can I do that? The problem is that I cannot save the features in csv or mat file. Also, the new audio feature replace the previous audio features thus giving me only feature vector i.e; comp_PCA1 gives me feature vector of 32600x1. But my files are 94 so the output should be 32600x94.
My code is given below:
clc
clear all
path_to_directory= dir ('**/*.wav'); % path to the directory
for i = 1:length(path_to_directory)
path= strcat(path_to_directory(i).folder, '\', path_to_directory(i).name);
[signal, Fs]= audioread(path); % audio read here
pitch = pwelch(signal); % pitch feature extraction part
[coeff,score] = pca(pitch); % pca for dimensionality reduction
Comp_PCA1 = score(:,1);
% % y (i,:)= coeff;
end
  댓글 수: 7
Ridwan Alam
Ridwan Alam 2019년 11월 20일
Great! Please mark this problem as solved or accept Walter's answer. Thanks!
Walter Roberson
Walter Roberson 2019년 11월 20일
(I had only posted as a Comment before, so it could not be Accepted.)

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2019년 11월 20일
path_to_directory= dir ('**/*.wav'); % path to the directory
for i = 1:length(path_to_directory)
filename = fullfile(path_to_directory(i).folder, path_to_directory(i).name);
[signal, Fs]= audioread(path); % audio read here
pitch = pwelch(signal); % pitch feature extraction part
[coeff,score] = pca(pitch); % pca for dimensionality reduction
this_Comp = score(:,1);
nR = size(this_Comp,1);
if i == 1
Comp_PCA1 = this_Comp;
elseif nR <= size(Comp_PCA1,1)
Comp_PCA1 = [Comp_PCA1(1:nR,:), this_Comp];
else
Comp_PCA1(:,i) = this_Comp(1:size(Comp_PCA1,1));
end
end
If I got everything right then this should make Comp_PCA1 correspond in length to the shortest of the files.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by