32 lines
935 B
Matlab
32 lines
935 B
Matlab
function computePitch(filename)
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
% function computePitch(filename)
|
|
% ex.: computeFormants("./praat_data/infoPitch.txt")
|
|
%
|
|
% Task: To compute the average pitch from a data set extracted from the formant
|
|
% listing tool of the Praat software.
|
|
%
|
|
% Inputs:
|
|
% -filename : String containing the directory of the file to read (.txt).
|
|
%
|
|
% Outputs:
|
|
%
|
|
%
|
|
% Author: Charles Stelandre - charles.stelandre@ecam.fr
|
|
% Date: 01/05/2025
|
|
%
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% Read the table as text to handle '--undefined--'
|
|
data = readtable(filename, 'Delimiter', ' ', 'MultipleDelimsAsOne', true);
|
|
|
|
% Convert F0_Hz column to numeric, converting '--undefined--' to NaN
|
|
F0_Hz = str2double(string(data.F0_Hz)); % Converts '--undefined--' to NaN
|
|
Time_s = data.Time_s;
|
|
|
|
% Compute mean while omitting NaN values
|
|
mean_F0_Hz = mean(F0_Hz, 'omitnan');
|
|
|
|
% Display the result
|
|
fprintf('Average F0_Hz: %.4f\n', mean_F0_Hz);
|
|
end |