fixed bug with index

This commit is contained in:
2018-11-09 04:33:43 -05:00
parent e31d9e6883
commit 4da2317db8
2 changed files with 6 additions and 4 deletions

View File

@@ -26,19 +26,20 @@ def speechmatics_converter(data: Dict[str, Union[Dict[str, str], List[Dict[str,
punc_before = False punc_before = False
punc_after = False punc_after = False
num_words = len(words) num_words = len(words)
index = 0
for index, w in enumerate(words): for i, w in enumerate(words):
word_start = float(w['time']) word_start = float(w['time'])
word_end = word_start + float(w['duration']) word_end = word_start + float(w['duration'])
confidence = float(w['confidence']) confidence = float(w['confidence'])
word = w['name'] word = w['name']
if word == '.': if word == '.':
continue continue
is_proper_noun = tagged_words[index][1] in PROPER_NOUN_TAGS is_proper_noun = tagged_words[i][1] in PROPER_NOUN_TAGS
next_word = None next_word = None
if index < num_words - 1: if i < num_words - 1:
next_word = words[index + 1]['name'] next_word = words[i + 1]['name']
if next_word == '.': if next_word == '.':
punc_after = '.' punc_after = '.'
@@ -53,6 +54,7 @@ def speechmatics_converter(data: Dict[str, Union[Dict[str, str], List[Dict[str,
'puncBefore': punc_before, 'puncBefore': punc_before,
}) })
index += 1
punc_after = False punc_after = False
return converted_words return converted_words