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