annotate Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_OtherFormants.m @ 4:92ca03a8fa99 tip

Update to ICASSP 2013 benchmark
author Dawn Black
date Wed, 13 Feb 2013 11:02:39 +0000
parents
children
rev   line source
Dawn@4 1 function [F1, F2, F3, F4, B1, B2, B3, B4, err_msg] = func_OtherFormants(wavfile, handles)
Dawn@4 2 % [F0, err] = func_SnackPitch(wavfile, windowsize, frameshift, maxF0, minF0)
Dawn@4 3 % Input: wavfile - input wav file
Dawn@4 4 % Output: F1, F2, F3, F4, B1, B2, B3, B4
Dawn@4 5 % err_msg - message of error
Dawn@4 6 % Notes: Function attempts to call an external command to produce a formant
Dawn@4 7 % output file which is read back as a vector. Formant output file format should
Dawn@4 8 % be 8 columns of formant values for each frame
Dawn@4 9 %
Dawn@4 10 % Warning: experimental function
Dawn@4 11 %
Dawn@4 12 % Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA
Dawn@4 13 % Copyright UCLA SPAPL 2009
Dawn@4 14
Dawn@4 15 % get settings and commands
Dawn@4 16 VSData = guidata(handles.VSHandle);
Dawn@4 17 outfile = [wavfile(1:end-3) 'fmt'];
Dawn@4 18
Dawn@4 19 C = textscan(VSData.vars.FormantsOtherCommand, '%s', 'delimiter', ' ');
Dawn@4 20 C = C{1};
Dawn@4 21
Dawn@4 22 command = [];
Dawn@4 23 F1 = NaN; F2 = NaN; F3 = NaN; F4 = NaN;
Dawn@4 24 B1 = NaN; B2 = NaN; B3 = NaN; B4 = NaN;
Dawn@4 25 err_msg = [];
Dawn@4 26
Dawn@4 27 for k=1:length(C)
Dawn@4 28 if (strcmp(C{k}, '$wavfile'))
Dawn@4 29 command = [command wavfile ' '];
Dawn@4 30 elseif (strcmp(C{k}, '$outfile'))
Dawn@4 31 command = [command outfile ' '];
Dawn@4 32 else
Dawn@4 33 command = [command C{k} ' '];
Dawn@4 34 end
Dawn@4 35 end
Dawn@4 36
Dawn@4 37 % attempt to run command
Dawn@4 38 [status, results] = system(command);
Dawn@4 39
Dawn@4 40 % error occured, exit
Dawn@4 41 if (status ~= 0)
Dawn@4 42 err_msg = 'Unable to execute command.';
Dawn@4 43
Dawn@4 44 % try to clean up files
Dawn@4 45 if (exist(outfile, 'file') ~= 0)
Dawn@4 46 delete(outfile);
Dawn@4 47 end
Dawn@4 48
Dawn@4 49 return;
Dawn@4 50 end
Dawn@4 51
Dawn@4 52 % now check if outfile exists
Dawn@4 53 if (exist(outfile, 'file') == 0)
Dawn@4 54 err_msg = 'Unable to find formant file.';
Dawn@4 55 return;
Dawn@4 56 end
Dawn@4 57
Dawn@4 58 % if file exists, read in the vectors
Dawn@4 59 fid = fopen(outfile, 'rt');
Dawn@4 60 if (fid == -1)
Dawn@4 61 err_msg = 'Unable to open formant file.';
Dawn@4 62 return;
Dawn@4 63 end
Dawn@4 64
Dawn@4 65 C = textscan(fid, '%f %f %f %f %f %f %f %f', 'delimiter', '\n');
Dawn@4 66 fclose(fid);
Dawn@4 67 F1 = C{1};
Dawn@4 68 F2 = C{2};
Dawn@4 69 F3 = C{3};
Dawn@4 70 F4 = C{4};
Dawn@4 71 B1 = C{5};
Dawn@4 72 B2 = C{6};
Dawn@4 73 B3 = C{7};
Dawn@4 74 B4 = C{8};
Dawn@4 75
Dawn@4 76
Dawn@4 77 % clean up
Dawn@4 78 delete(outfile);
Dawn@4 79