annotate Code/Descriptors/Matlab/Common/detect_VoicedUnvoiced.m @ 1:a3d62264030c

tested and working
author Dawn Black <dawn.black@eecs.qmul.ac.uk>
date Mon, 10 Sep 2012 09:13:53 +0100
parents ea0c737c6323
children 92ca03a8fa99
rev   line source
dawn@1 1 function [vuv] = detect_VoicedUnvoiced( sampleWavFileName, OVERWRITE )
dawn@0 2
dawn@0 3 sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 );
dawn@0 4 fileName = [ sampleFileName '_VUV.txt'];
dawn@0 5 fileID = fopen( fileName );
dawn@0 6 %
dawn@1 7 if( (fileID < 0) || (OVERWRITE) )
dawn@0 8 %---------------- GET THE SILENT FRAME VALUES -------------------
dawn@0 9
dawn@0 10 % only wish to consider pitch values from voiced frames.
dawn@0 11 % silent and unvoiced frames will produce pitch values that
dawn@0 12 % are random and therefore will bias our results
dawn@0 13 segmentFrames = detect_Silence( sampleFileName, 0 );
dawn@0 14
dawn@0 15 % remove the silent frames
dawn@1 16 [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] );
dawn@0 17 [ silentFrames ] = removeSilentData( segmentFrames, noOfFrames );
dawn@0 18
dawn@0 19 % [vuv] = voicingByClustering( nonSilentAudio, fs, noOfFrames, frameLength );
dawn@0 20 [vuv] = calculate_VoicedUnvoicedDecision( sampleFileName, x, fs, frameLength, noOfFrames, silentFrames );
dawn@0 21
dawn@0 22 noOfValidFrames = length(vuv);
dawn@0 23
dawn@0 24 % plotAudioFrameByType( nonSilentAudio, noOfValidFrames, vuv, frameLength );
dawn@0 25 % fclose( fileID );
dawn@0 26 fileID = fopen( fileName, 'w');
dawn@0 27 for i = 1 : length(vuv)
dawn@0 28 fprintf(fileID,'%d %d \n', i, vuv(i));
dawn@0 29 end
dawn@0 30 fclose( fileID );
dawn@0 31 fileID = fopen( fileName );
dawn@0 32 end
dawn@0 33
dawn@0 34 vuv = fscanf( fileID, '%d', inf );
dawn@0 35 vuv = vuv( 2:2:end );
dawn@0 36
dawn@0 37 fclose( fileID );