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
5 changes: 3 additions & 2 deletions funasr/utils/postprocess_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,13 @@ def get_event(s):
for i in range(1, len(s_list)):
if len(s_list[i]) == 0:
continue
if get_event(s_list[i]) == cur_ent_event and get_event(s_list[i]) != None:
event = get_event(s_list[i])
if event == cur_ent_event and event != None:
s_list[i] = s_list[i][1:]
if len(s_list[i]) == 0:
continue
# else:
cur_ent_event = get_event(s_list[i])
cur_ent_event = event
if get_emo(s_list[i]) != None and get_emo(s_list[i]) == get_emo(new_s):
new_s = new_s[:-1]
segment = s_list[i].strip()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,13 @@ def get_event(s):
for i in range(1, len(s_list)):
if len(s_list[i]) == 0:
continue
if get_event(s_list[i]) == cur_ent_event and get_event(s_list[i]) != None:
event = get_event(s_list[i])
if event == cur_ent_event and event != None:
s_list[i] = s_list[i][1:]
if len(s_list[i]) == 0:
continue
# else:
cur_ent_event = get_event(s_list[i])
cur_ent_event = event
if get_emo(s_list[i]) != None and get_emo(s_list[i]) == get_emo(new_s):
new_s = new_s[:-1]
segment = s_list[i].strip()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,13 @@ def get_event(s):
for i in range(1, len(s_list)):
if len(s_list[i]) == 0:
continue
if get_event(s_list[i]) == cur_ent_event and get_event(s_list[i]) != None:
event = get_event(s_list[i])
if event == cur_ent_event and event != None:
s_list[i] = s_list[i][1:]
if len(s_list[i]) == 0:
continue
# else:
cur_ent_event = get_event(s_list[i])
cur_ent_event = event
if get_emo(s_list[i]) != None and get_emo(s_list[i]) == get_emo(new_s):
new_s = new_s[:-1]
segment = s_list[i].strip()
Expand Down
26 changes: 26 additions & 0 deletions tests/test_rich_transcription_event_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,29 @@ def test_distinct_event_only_segments_remain_visible(postprocess):
assert postprocess.rich_transcription_postprocess(text) == (
postprocess.event_dict["<|Applause|>"] + postprocess.event_dict["<|Laughter|>"]
)


@pytest.mark.parametrize("event", ["<|Cough|>", "<|Sneeze|>", "<|Applause|>"])
def test_repeated_event_with_text_across_three_segments(postprocess, event):
text = (
f"<|en|>{event}hello"
f"<|en|>{event}world"
f"<|en|>{event}again"
)
emoji = postprocess.event_dict[event]

assert postprocess.rich_transcription_postprocess(text) == f"{emoji}hello world again"


def test_different_event_between_same_events_keeps_all_emojis(postprocess):
text = (
"<|en|><|Applause|>hello"
"<|en|><|Laughter|>world"
"<|en|><|Applause|>again"
)
applause = postprocess.event_dict["<|Applause|>"]
laughter = postprocess.event_dict["<|Laughter|>"]

assert postprocess.rich_transcription_postprocess(text) == (
f"{applause}hello{laughter}world{applause}again"
)
Loading