Mercurial > hg > emotion-detection-top-level
view Code/Descriptors/Matlab/Common/detect_pitch.m @ 4:92ca03a8fa99 tip
Update to ICASSP 2013 benchmark
author | Dawn Black |
---|---|
date | Wed, 13 Feb 2013 11:02:39 +0000 |
parents | ea0c737c6323 |
children |
line wrap: on
line source
function [ pitch ] = detect_pitch( sampleWavFileName, OVERWRITE ) % open original pitch calculation sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); fileName = [ sampleFileName '_YIN_pitch.txt']; % read pitch metrics from file fileID = fopen( fileName ); if( (fileID <= 0) || (OVERWRITE) ) %does the file exist? % no disp('WARNING: MISSING PITCH FILE'); %calculate it [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] ); % perform pitch detection framePrd = calculate_pitchYIN( sampleFileName, x, fs, frameLength ); fileID = fopen( fileName, 'w'); for( i=1:length( framePrd )) fprintf(fileID, '%d %f \n', framePrd(i,1), framePrd(i,2) ); end fclose( fileID ); fileID = fopen( fileName ); end pitch = fscanf( fileID, '%f', inf ); pitch = pitch(2:2:end); fclose( fileID ); end