Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,18 @@ def abbr_dispose(words: List[Any], time_stamp: List[List] = None) -> List[Any]:
if num in abbr_begin:
if time_stamp is not None:
begin = time_stamp[ts_nums[num]][0]
word_lists.append(words[num].upper())
abbr_word = words[num].upper()
num += 1
while num < words_size:
if num in abbr_end:
word_lists.append(words[num].upper())
abbr_word += words[num].upper()
last_num = num
break
else:
if words[num].encode("utf-8").isalpha():
word_lists.append(words[num].upper())
abbr_word += words[num].upper()
num += 1
word_lists.append(abbr_word)
if time_stamp is not None:
end = time_stamp[ts_nums[num]][1]
ts_lists.append([begin, end])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,18 @@ def abbr_dispose(words: List[Any], time_stamp: List[List] = None) -> List[Any]:
if num in abbr_begin:
if time_stamp is not None:
begin = time_stamp[ts_nums[num]][0]
word_lists.append(words[num].upper())
abbr_word = words[num].upper()
num += 1
while num < words_size:
if num in abbr_end:
word_lists.append(words[num].upper())
abbr_word += words[num].upper()
last_num = num
break
else:
if words[num].encode("utf-8").isalpha():
word_lists.append(words[num].upper())
abbr_word += words[num].upper()
num += 1
word_lists.append(abbr_word)
if time_stamp is not None:
end = time_stamp[ts_nums[num]][1]
ts_lists.append([begin, end])
Expand Down
20 changes: 20 additions & 0 deletions tests/test_sentence_postprocess_timestamps.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,26 @@ def test_untimed_transcription_still_accepts_filtered_tokens(self):
("你好", ["你", "好"]),
)

def test_spelled_out_letters_are_one_word_with_one_timestamp(self):
self.assert_timestamps(
["我", "用", "a", "i", "写", "代", "码"],
["我", "用", "AI", "写", "代", "码"],
[[0, 100], [100, 200], [200, 400], [400, 500], [500, 600], [600, 700]],
)
self.assert_timestamps(
["i", "b", "m", "is", "here"],
["IBM", "is", "here"],
[[0, 300], [300, 400], [400, 500]],
)

def test_spelled_out_letters_are_one_word_without_timestamps(self):
for path in POSTPROCESS_UTILS:
with self.subTest(path=path):
self.assertEqual(
_load_sentence_postprocess(path)(["看", "c", "c", "t", "v", "新", "闻"]),
("看CCTV新闻", ["看", "CCTV", "新", "闻"]),
)


if __name__ == "__main__":
unittest.main()
Loading