| 1 |
function vtQueryVisual(STRQuery) |
| 2 |
|
| 3 |
%======================================================================================== |
| 4 |
% 1. Jaw Position 4. Tongue Apex 7. Larynx Height 10. Nasal Cavity |
| 5 |
% 2. Tongue Position 5. Lip Aperture 8. Glottal Aperture 11. Phoneme Label |
| 6 |
% 3. Tongue Shape 6. Lip Protrusion 9. Glottal Frequency |
| 7 |
%======================================================================================== |
| 8 |
% 1 2 3 4 5 6 7 8 9 10 11 |
| 9 |
% JW TP TS TA LA LP LH GA FX NS |
| 10 |
% 3 3 3 3 3 3 3 3 3 3 Max |
| 11 |
% 0 0 0 0 0 0 0 0 0 0 Relax |
| 12 |
% -3 3 -3 -3 -3 -3 -3 -3 -3 -3 Min |
| 13 |
%======================================================================================== |
| 14 |
VocalTractVecToTimeCodeBook = ... |
| 15 |
{[ 0.5, -2 , 1 ,-2 , 1 , -1 , 0 , 0, 0, 0], 'i' ; % 1 |
| 16 |
[ 0.5, -2 , 1 ,-2 , 0 , 2 , 0 , 0, 0, 0], 'y' ; % 2 (\"u) |
| 17 |
[-1 , -1 , 1 ,-2 , 1 ,-0.5 , 0 , 0, 0, 0], 'e' ; % 3 |
| 18 |
[-1 , -1 , 1 ,-2 , 0 , 2 , 0 , 0, 0 , 0 ], '2' ; % 4 (\"o) |
| 19 |
[-1.5, 2.5, 0 ,-0.5 , 0 , 2 , 0 , 0, 0 , 0 ], 'E' ; % 5 (\"a) |
| 20 |
[-1.5, 1.5, 0 , 0.5 , 0.5, -0.5 , 0 , 0, 0 , 0 ], '@' ; % 6 (Schwa) |
| 21 |
[-1.5, 2.5, 0 ,-0.5 , 0.5, -0.5 , 0 , 0, 0 , 0 ], 'a' ; % 7 |
| 22 |
[0.5 , 2 , 1.5 ,-2 ,-1 , 1.5 , 0 , 0, 0 , 0 ], 'u' ; % 8 |
| 23 |
[-0.4, 3.0, 1.5 , 0 ,-0.3, 0 , 0 , 0, 0 , 0 ], 'o' ; % 9 |
| 24 |
... %-------------------------------------------------------------------Unvoiced Cons.-------- |
| 25 |
[0 , 0 , 0 , 0 ,-3 , 0 , 0 ,-3 , -3 , -3 ], 'p' ; % 10 % UPlosives |
| 26 |
[0 , -0.5 ,-1 , 2.3 , 0 , 0 , 0 ,-3 , -3 , -3 ], 't' ; % 11 |
| 27 |
[0 , -1.5 , 3 , -3 , 0 , 0 , 0 ,-3 , -3 , -3 ], 'k' ; % 12 |
| 28 |
[2 , 1 , 0 , 0 ,-1.5, -2 , 0 ,-3 , -3 , -3 ], 'f' ; % 13 % UFricatives |
| 29 |
[2.5 , 0 , 0 , 0.4 , 0 , 0 , 0 ,-3 , -3 , -3 ], 's' ; % 14 |
| 30 |
[0 , -1 , 3 , -3 , 0 , 0 , 0 ,-3 , -3 , -3 ], 'x' ; % 15 |
| 31 |
...%----------------------------------------------------------------- Voiced Cons. -------- |
| 32 |
[0 , 0 , 0 , 0 ,-3 , 0 ,-1 , -1 , 0 , -3 ], 'b' ; % 16 % VPlosives |
| 33 |
[0 , -0.5 ,-1 , 2.3 , 0 , 0 , 0 , -1 , 0 , -3 ], 'd' ; % 17 |
| 34 |
[0 , -1.5 , 3 , -3 , 0 , 0 , 0 , -1 , 0 , -3 ], 'g' ; % 18 |
| 35 |
[1 , 0 , 0 , 3 , 0 , 0 , 0 , -1 , 0 , 0 ], 'r' ; % 19 % Rolled |
| 36 |
[0 , -2 , 3 , 3 , 0 , 0 , 0 , -1 , 0 , 0 ], 'l' ; % 20 % Lateral |
| 37 |
[0 , 2.3 , 2.5 , -2 , 0 , 0 , 0 , -1 , 0 , 0 ], 'R' ; % 21 % Approximants |
| 38 |
[1 , 0 , 2 , 0 , 0 , 0 , 0 , -1 , 0 , 0 ], 'j' ; % 22 |
| 39 |
[2 , 1 , 0 , 0 ,-1.5, -2 , 0 , -1 , 0 , 0 ], 'v' ; % 23 % VFricatives |
| 40 |
[2.5 , 0 , 0 , 0.4 , 0 , 0 , 0 , -1 , 0 , 0 ], 'z' ; % 24 |
| 41 |
[0 , 0 , 0 , 0 ,-3 , -1 , 0 , -1 , 0 , 0 ], 'm' ; % 25 % Nasals |
| 42 |
[0.5 , 0 , 0 , 3 , 0 , 0 , 0 , -1 , 0 , 0 ], 'n' }; % 26 |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
VocalTractVecToTime = FindVectorsFromCodeBook(VocalTractVecToTimeCodeBook, STRQuery); |
| 47 |
|
| 48 |
NumberOfTimeFrames = size(VocalTractVecToTime,1); |
| 49 |
VocalTractVecToTimeSTR = Mat2StrCustom(VocalTractVecToTime); |
| 50 |
|
| 51 |
%---------------- Add some commands before and after --------------- |
| 52 |
LatexDefCommandsOfCordsPre = ['\newarray\SpeakVec' ... |
| 53 |
'\readarray{SpeakVec}{']; |
| 54 |
|
| 55 |
LatexDefCommandsOfCordsPost = ['}'... |
| 56 |
' \dataheight=11' ... |
| 57 |
' \def\Nframes{' num2str(NumberOfTimeFrames+1) '}']; |
| 58 |
|
| 59 |
% %------- Create the Coordinates file ---------------- |
| 60 |
fid = fopen('vtLatex_TimeParams.tex', 'w'); |
| 61 |
|
| 62 |
fwrite(fid,sprintf('%s %s %s',LatexDefCommandsOfCordsPre,... |
| 63 |
VocalTractVecToTimeSTR,... |
| 64 |
LatexDefCommandsOfCordsPost),'char'); |
| 65 |
fclose(fid); |
| 66 |
|
| 67 |
%---------------- START the Compilers ----------------------------- |
| 68 |
%-- tex2dvi |
| 69 |
!latex -interaction=nonstopmode vtLatex_AnimationLauncher.tex |
| 70 |
%--- dvi2ps |
| 71 |
!dvips -o vtLatex_AnimationLauncher.ps vtLatex_AnimationLauncher.dvi |
| 72 |
%---- ps2pdf |
| 73 |
!ps2pdf vtLatex_AnimationLauncher.ps |
| 74 |
%--- view pdf |
| 75 |
!AcroRd32 vtLatex_AnimationLauncher.pdf |
| 76 |
|
| 77 |
|
| 78 |
%=================================================================== |
| 79 |
% Matrix to a String Ordering with & intervening |
| 80 |
%=================================================================== |
| 81 |
function STR = Mat2StrCustom(Matr) |
| 82 |
|
| 83 |
R = size(Matr,1); |
| 84 |
C = length(Matr{1,1}); |
| 85 |
|
| 86 |
STR = []; |
| 87 |
for IndRow= 1:R |
| 88 |
for IndCol = 1:C |
| 89 |
STR = [STR num2str(Matr{IndRow,1}(IndCol)) '&']; |
| 90 |
end |
| 91 |
STR = [STR Matr{IndRow,2} '&']; |
| 92 |
end |
| 93 |
%STR = STR(1:end-1); |
| 94 |
|
| 95 |
%=================================================================== |
| 96 |
% QUERY CODEBOOK |
| 97 |
%=================================================================== |
| 98 |
function OutVecs = FindVectorsFromCodeBook(InVecs, STRQuery) |
| 99 |
|
| 100 |
NPhonemes = length(STRQuery); |
| 101 |
|
| 102 |
NumericBookPhonemes = zeros(1,NPhonemes); |
| 103 |
|
| 104 |
BookOfPhonemes = InVecs(:,2); |
| 105 |
|
| 106 |
for iPhoneme = 1:NPhonemes, |
| 107 |
NumericBookPhonemes(iPhoneme) = find(strcmp(BookOfPhonemes,STRQuery(iPhoneme))); |
| 108 |
end |
| 109 |
|
| 110 |
OutVecs = InVecs(NumericBookPhonemes,:); |
| 111 |
return |
| 112 |
|
| 113 |
|
| 114 |
|