Skip to content

Commit

Permalink
Fixing (1) HierarchicalBehavioralTable.add_interval kwargs handling a…
Browse files Browse the repository at this point in the history
…nd (2) issue with hyphens in syllables_data_extractor and timitsounds_converter (by switching to comma)
  • Loading branch information
emilyps14 committed Sep 30, 2020
1 parent e9b4ccc commit 274e746
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def __init__(self, **kwargs):
allow_extra=True)
def add_interval(self, **kwargs):
# automatically populate the time with the start time of the first element of the next tier
if getattr(kwargs, 'start_time', None) is None:
if kwargs.get('start_time', None) is None:
kwargs.update(start_time=self['next_tier'].target.table['start_time'][kwargs['next_tier'][0]])

if getattr(kwargs, 'stop_time', None) is None:
if kwargs.get('stop_time', None) is None:
kwargs.update(stop_time=self['next_tier'].target.table['stop_time'][kwargs['next_tier'][-1]])

super().add_interval(**kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def syllables_data_extractor(syllables_phonemes_data):
for i in uniq_syl:
x = syllables_phonemes_data[syllables_phonemes_data['syllable_number'] == i].reset_index()
data = [
[x['start_time'].iloc[0], x['stop_time'].iloc[-1], '-'.join(x["phonemes"]), x['syllable_number'].iloc[0]]]
[x['start_time'].iloc[0], x['stop_time'].iloc[-1], ','.join(x["phonemes"]), x['syllable_number'].iloc[0]]]
uniq_row = pd.DataFrame(data, columns=['start_time', 'stop_time', 'label', 'syllable_number'])
syllables_data = syllables_data.append(uniq_row, ignore_index=True)
last_row = pd.DataFrame([[syllables_data['stop_time'].iloc[-1], syllables_data['stop_time'].iloc[0], 'h#', 0]],
Expand Down Expand Up @@ -250,7 +250,7 @@ def timitsounds_converter(phonemes_data, syllables_data, words_data, sentences_d
syllables = HBTSyllables(lower_tier_table=phonemes)
cum_phonemes_count = 0
for ind in syllables_data.index:
phonemes_count = len(syllables_data['label'][ind].split('-'))
phonemes_count = len(syllables_data['label'][ind].split(','))
tier_ind = list(range(cum_phonemes_count, cum_phonemes_count + phonemes_count))
cum_phonemes_count = cum_phonemes_count + phonemes_count
syllables.add_interval(label=syllables_data['label'][ind],
Expand Down

0 comments on commit 274e746

Please sign in to comment.