Reputation: 811
I am editing my previous post which I could not explain properly before. I have written this code which is,
param_values = {
'aa' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,1.0], [-1,-1]],
'ae' : [[-1,-1], [-1,-1], [0.3,0.4], [-1,-1], [0.15,1.0], [-1,-1]],
'ah' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,1.0], [-1,-1]],
'ao' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.3,1.0], [-1,-1]],
'b' : [[-1,-1], [0.2,1.0], [-1,-1], [-1,-1], [0.15,0.2], [-1,-1]],
'ch' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.4], [-1,-1]],
'd' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.4], [-1,-1]],
'dh' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.35], [-1,-1]],
'dx' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.35], [-1,-1]],
'eh' : [[-1,-1], [-1,-1], [0.1,0.5], [-1,-1], [0.4,0.7], [-1,-1]],
'er' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.5], [-1,-1]],
'ey' : [[-1,-1], [-1,-1], [0.3,1.0], [-1,-1], [0.3,0.5], [-1,-1]],
'f' : [[0.5,1.0], [-1,-1], [-1,-1], [-1,-1], [-1,-1], [-1,-1]],
'g' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.8], [-1,-1]],
'hh' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.8], [-1,-1]],
'ih' : [[-1,-1], [-1,-1], [0.3,1.0], [-1,-1], [0.05,0.15], [-1,-1]],
'iy' : [[-1,-1], [-1,-1], [0.3,1.0], [-1,-1], [0.1,0.15], [-1,-1]],
'jh' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.6], [-1,-1]],
'k' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.8], [-1,-1]],
'l' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.6], [-1,-1]],
'm' : [[-1,-1], [0.2,1.0], [-1,-1], [-1,-1], [0.15,0.2], [-1,-1]],
'n' : [[-1,-1], [-1,-1], [-1,-1], [0.3,1.0], [-1,-1], [-1,-1]],
'ng' : [[-1,-1], [-1,-1], [0.3,1.0], [-1,-1], [0.09,0.3], [-1,-1]],
'p' : [[-1,-1], [0.2,1.0], [-1,-1], [-1,-1], [0.15,0.2], [-1,-1]],
'r' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.6], [-1,-1]],
's' : [[-1,-1], [-1,-1], [-1,-1], [0.3,1.0], [-1,-1], [-1,-1]],
'sh' : [[-1,-1], [-1,-1], [-1,-1], [0.3,1.0], [-1,-1], [-1,-1]],
't' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.4], [-1,-1]],
'th' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.2], [-1,-1]],
'uh' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.5,1.0]],
'uw' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.5,1.0]],
'v' : [[0.5,1.0], [-1,-1], [-1,-1], [-1,-1], [-1,-1], [-1,-1]],
'w' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.2,1.0]],
'y' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.4], [-1,-1]],
'z' : [[-1,-1], [-1,-1], [-1,-1], [0.3,1.0], [-1,-1], [-1,-1]],
'zh' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,0.6], [-1,-1]]
'o' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.4,1.0]]
}
def coart(phonemeFile) :
""" Coarticulation function where forward and backward coarticulation take place a and parameter values are generated"""
with open("syllabifiedPhonemes.txt", "r") as pFile :
for line in tFile :
line = line.split()
if line == " ' " :
continue
param_values is the list of phonemes which has the corresponding lists of each phoneme. The list each phoneme has, relates to a blend shape slider value I got from Maya. I have 6 blendshapes in Maya which are lower_lip_under_upper_teeth,lips_touch,lips_spread, teeth touch,jaw_open and lips_round. So these values are the ranges which a phoneme has for each slider value.
[-1,-1] indicates that particular blendshape is not in use. And the other values are the ranges in which the shapes can move.
The list shows, mostly its just a single lip shape that is active for one phoneme and the rest of them are [-1,-1]. But for some phonemes there are 2 or 3 lip shapes active at the same time. I have manually animated them in Maya. The values for lip shape varies from 0 to 1.
The contents of the input file, syllabifiedPhonemes.txt is,
sh iy ' hh eh ' t er ' t aa r k ' s uw t n ' k r iy s ' hh iy ' w aa ' sh w aa dx ' er ' l ih ' y er
The program should go through all of these phonemes in the file and set the values of its corresponding lip shapes by referring to the list above. Those values should be stored so that further work can be carried out. The single quote represents syllable boundaries. At first the program should go through the phonemes ignoring syllable boundaries and save their lip shape values for all the shapes. Then in the next stage it should start looking inside each boundary.
So far I only have this but I am blank on how to proceed further. I guess I have explained my query properly. Thank you.
The values are the ones for the shapes present inside the shapes list. Could anyone help please. Thank you.
Upvotes: 2
Views: 159
Reputation: 125137
Presuming that you already know which phonemes are related to which lip shapes, it sounds like you just need to build a dictionary. This is just an example, probably nonsense in terms of your problem domain:
lip_shapes = {
'aa': ['neutral', 'lower lip under upper teeth'],
'ae': ['lips touch', 'lip spread'],
# etc...
}
So you can find the lip shapes for a phoneme like this: lip_shapes['aa']
The next thing you'll want to do is represent the lip shapes with constants rather than strings:
NEUTRAL = 0
LOWER_LIP_UNDER_UPPER_TEETH = 1
LIPS_TOUCH = 2
LIP_SPREAD = 3
lip_shapes = {
'aa': [NEUTRAL, LOWER_LIP_UNDER_UPPER_TEETH],
# etc...
}
Using constant names for the lip shapes, rather than long strings, will make your programming less prone to typos. (You will cause a NameError
rather than having a subtly different string.)
Is that any help to you? Can you see how to turn your data into this form?
Upvotes: 1