Skip to content

Commit

Permalink
testing -m and -y interaction issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWilbanks committed Jun 12, 2021
1 parent f51418c commit 59fe422
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
18 changes: 11 additions & 7 deletions bin/faseAlign
Original file line number Diff line number Diff line change
Expand Up @@ -732,17 +732,21 @@ def process_tg_intervals(tmppath,output_intervals,args_syllables,custom_words):
output_intervals[speaker]["syllables"] = []
for entry in output_intervals[speaker]["words"]:
if entry[2] not in ['sp','{SIL}','{LG}','{BR}','{CG}','{NS}']:
current = spanish_word(entry[2])
word_s = entry[0]
word_e = entry[1]
phones = [p for p in output_intervals[speaker]["phones"] if ((p[0] >= word_s) and (p[1] <= word_e))] # all phones which fall within word times

# override phones generated from spanish_word() for words defined in the custom dictionary
if entry[2] in custom_words:
print(entry[2])
current = spanish_word(entry[2], override = True, custom_phones = phones)
else:
current = spanish_word(entry[2])

# sanity check that custom phone override process was successful
if len(phones) != len(current.phones):
# override phones generated from spanish_word() for words defined in the custom dictionary
if current.orth.upper() in custom_words:
print(current)
current.phones = phones
else:
print('WARNING! - unequal phone numbers: ' + str(phones) + ' - ' + str(current.phones)) # TO-DO: decide on solution for words with double entries in dictionary and functionality of spanish_word.to_phones()
print('WARNING! - unequal phone numbers: ' + str(phones) + ' - ' + str(current.phones))

for syll in current.syllables:
curr_syll = current.syllables[syll]
syll_s = phones[0][0] # start time of first phone in syllable
Expand Down
8 changes: 6 additions & 2 deletions faseAlign/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ class spanish_word(object):
corr_tups = [('ll','y'), ('qu','k'), ('ce','se'), ('cé','sé'), ('ci','si'), ('cí','sí'), ('ge','xe'), ('gé','xé'), ('gi','xi'), ('gí','xí'), ('j','x'), ('v','b'), ('z','s'), ('w','u'), ('rr','R'), ('\\br','R'), ('ñ','1'), ('ch','2'), ('c','k'), ('h',''), ('ü','u'), ('gui','gi'), ('gue','ge'), ('guí','gí'), ('gué','gé')]
corr_tups2 = [('ú','u'), ('ó','o'), ('í','i'), ('é','e'), ('á','a')]

def __init__(self, word):
def __init__(self, word, override = False, custom_phones = None):
self.orth = word.lower()
self.phones = self.to_phones()
# overriding phone process for user-defined custom words
if override == True:
self.phones = custom_phones
else:
self.phones = self.to_phones()
self.syllables = self.process_syllables()
# Transform numbers back to digraphs
self.phones[:] = [re.sub('1','NY',p) for p in self.phones]
Expand Down

0 comments on commit 59fe422

Please sign in to comment.