I have an audio .wav file of someone's speech of which I want to find the mean fundamental frequency. Till now, all I have managed to do is load the data into a vector and (roughly) filter the silence out. I referred to a MATLAB example of finding the fundamental frequency, but it lies way out of the range of the mean fundamental frequencies which I have in a dataset I am referring to. The code on MATLAB is so-
function F0 = fundafreq(data) % Copied from matlab site F0 = 0; Fs = 48000; % My sampling frequency [b0,a0] = butter(2,325/(Fs/2)); xin = abs(data); xin = filter(b0,a0,xin); xin = xin-mean(xin); x2 = zeros(length(xin),1); x2(1:length(data)-1) = xin(2:length(data)); zc = length(find((xin>0 & x2<0) | (xin<0 & x2>0))); F0 = 0.5*Fs*zc/length(data); end
This gives me the fundamental frequency of around 40 Hz whereas my data set has mean fundamental frequencies not more than 1. I am only a beginner when it comes to digital signal processing, so I am not completely aware whether this code is giving me the answer or whether I need further calculations.
Also, it would be preferable if I could calculate this without needing the sampling frequency.