mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
bugfix v1.1.11
This commit is contained in:
parent
5fc1d918aa
commit
2330e58f5f
@ -125,11 +125,11 @@ def abbr_dispose(words: List[Any], time_stamp: List[List] = None) -> List[Any]:
|
|||||||
if time_stamp is not None:
|
if time_stamp is not None:
|
||||||
end = time_stamp[ts_nums[num]][1]
|
end = time_stamp[ts_nums[num]][1]
|
||||||
ts_lists.append([begin, end])
|
ts_lists.append([begin, end])
|
||||||
else:
|
else:
|
||||||
|
word_lists.append(words[num])
|
||||||
# length of time_stamp may not equal to length of words because of the (somehow improper) threshold set in timestamp_tools.py line 46, e.g., length of time_stamp can be zero but length of words is not.
|
# length of time_stamp may not equal to length of words because of the (somehow improper) threshold set in timestamp_tools.py line 46, e.g., length of time_stamp can be zero but length of words is not.
|
||||||
# Moreover, move "word_lists.append(words[num])" into if clause, to keep length of word_lists and length of ts_lists equal.
|
# Moreover, move "word_lists.append(words[num])" into if clause, to keep length of word_lists and length of ts_lists equal.
|
||||||
if time_stamp is not None and ts_nums[num]<len(time_stamp) and words[num] != " ":
|
if time_stamp is not None and ts_nums[num] < len(time_stamp) and words[num] != " ":
|
||||||
word_lists.append(words[num])
|
|
||||||
begin = time_stamp[ts_nums[num]][0]
|
begin = time_stamp[ts_nums[num]][0]
|
||||||
end = time_stamp[ts_nums[num]][1]
|
end = time_stamp[ts_nums[num]][1]
|
||||||
ts_lists.append([begin, end])
|
ts_lists.append([begin, end])
|
||||||
@ -302,28 +302,29 @@ def sentence_postprocess_sentencepiece(words):
|
|||||||
sentence = "".join(word_lists)
|
sentence = "".join(word_lists)
|
||||||
return sentence, real_word_lists
|
return sentence, real_word_lists
|
||||||
|
|
||||||
|
|
||||||
emo_dict = {
|
emo_dict = {
|
||||||
"<|HAPPY|>": "😊",
|
"<|HAPPY|>": "😊",
|
||||||
"<|SAD|>": "😔",
|
"<|SAD|>": "😔",
|
||||||
"<|ANGRY|>": "😡",
|
"<|ANGRY|>": "😡",
|
||||||
"<|NEUTRAL|>": "",
|
"<|NEUTRAL|>": "",
|
||||||
"<|FEARFUL|>": "😰",
|
"<|FEARFUL|>": "😰",
|
||||||
"<|DISGUSTED|>": "🤢",
|
"<|DISGUSTED|>": "🤢",
|
||||||
"<|SURPRISED|>": "😮",
|
"<|SURPRISED|>": "😮",
|
||||||
}
|
}
|
||||||
|
|
||||||
event_dict = {
|
event_dict = {
|
||||||
"<|BGM|>": "🎼",
|
"<|BGM|>": "🎼",
|
||||||
"<|Speech|>": "",
|
"<|Speech|>": "",
|
||||||
"<|Applause|>": "👏",
|
"<|Applause|>": "👏",
|
||||||
"<|Laughter|>": "😀",
|
"<|Laughter|>": "😀",
|
||||||
"<|Cry|>": "😭",
|
"<|Cry|>": "😭",
|
||||||
"<|Sneeze|>": "🤧",
|
"<|Sneeze|>": "🤧",
|
||||||
"<|Breath|>": "",
|
"<|Breath|>": "",
|
||||||
"<|Cough|>": "🤧",
|
"<|Cough|>": "🤧",
|
||||||
}
|
}
|
||||||
|
|
||||||
lang_dict = {
|
lang_dict = {
|
||||||
"<|zh|>": "<|lang|>",
|
"<|zh|>": "<|lang|>",
|
||||||
"<|en|>": "<|lang|>",
|
"<|en|>": "<|lang|>",
|
||||||
"<|yue|>": "<|lang|>",
|
"<|yue|>": "<|lang|>",
|
||||||
@ -333,81 +334,90 @@ lang_dict = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emoji_dict = {
|
emoji_dict = {
|
||||||
"<|nospeech|><|Event_UNK|>": "❓",
|
"<|nospeech|><|Event_UNK|>": "❓",
|
||||||
"<|zh|>": "",
|
"<|zh|>": "",
|
||||||
"<|en|>": "",
|
"<|en|>": "",
|
||||||
"<|yue|>": "",
|
"<|yue|>": "",
|
||||||
"<|ja|>": "",
|
"<|ja|>": "",
|
||||||
"<|ko|>": "",
|
"<|ko|>": "",
|
||||||
"<|nospeech|>": "",
|
"<|nospeech|>": "",
|
||||||
"<|HAPPY|>": "😊",
|
"<|HAPPY|>": "😊",
|
||||||
"<|SAD|>": "😔",
|
"<|SAD|>": "😔",
|
||||||
"<|ANGRY|>": "😡",
|
"<|ANGRY|>": "😡",
|
||||||
"<|NEUTRAL|>": "",
|
"<|NEUTRAL|>": "",
|
||||||
"<|BGM|>": "🎼",
|
"<|BGM|>": "🎼",
|
||||||
"<|Speech|>": "",
|
"<|Speech|>": "",
|
||||||
"<|Applause|>": "👏",
|
"<|Applause|>": "👏",
|
||||||
"<|Laughter|>": "😀",
|
"<|Laughter|>": "😀",
|
||||||
"<|FEARFUL|>": "😰",
|
"<|FEARFUL|>": "😰",
|
||||||
"<|DISGUSTED|>": "🤢",
|
"<|DISGUSTED|>": "🤢",
|
||||||
"<|SURPRISED|>": "😮",
|
"<|SURPRISED|>": "😮",
|
||||||
"<|Cry|>": "😭",
|
"<|Cry|>": "😭",
|
||||||
"<|EMO_UNKNOWN|>": "",
|
"<|EMO_UNKNOWN|>": "",
|
||||||
"<|Sneeze|>": "🤧",
|
"<|Sneeze|>": "🤧",
|
||||||
"<|Breath|>": "",
|
"<|Breath|>": "",
|
||||||
"<|Cough|>": "😷",
|
"<|Cough|>": "😷",
|
||||||
"<|Sing|>": "",
|
"<|Sing|>": "",
|
||||||
"<|Speech_Noise|>": "",
|
"<|Speech_Noise|>": "",
|
||||||
"<|withitn|>": "",
|
"<|withitn|>": "",
|
||||||
"<|woitn|>": "",
|
"<|woitn|>": "",
|
||||||
"<|GBG|>": "",
|
"<|GBG|>": "",
|
||||||
"<|Event_UNK|>": "",
|
"<|Event_UNK|>": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
emo_set = {"😊", "😔", "😡", "😰", "🤢", "😮"}
|
emo_set = {"😊", "😔", "😡", "😰", "🤢", "😮"}
|
||||||
event_set = {"🎼", "👏", "😀", "😭", "🤧", "😷",}
|
event_set = {
|
||||||
|
"🎼",
|
||||||
|
"👏",
|
||||||
|
"😀",
|
||||||
|
"😭",
|
||||||
|
"🤧",
|
||||||
|
"😷",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def format_str_v2(s):
|
def format_str_v2(s):
|
||||||
sptk_dict = {}
|
sptk_dict = {}
|
||||||
for sptk in emoji_dict:
|
for sptk in emoji_dict:
|
||||||
sptk_dict[sptk] = s.count(sptk)
|
sptk_dict[sptk] = s.count(sptk)
|
||||||
s = s.replace(sptk, "")
|
s = s.replace(sptk, "")
|
||||||
emo = "<|NEUTRAL|>"
|
emo = "<|NEUTRAL|>"
|
||||||
for e in emo_dict:
|
for e in emo_dict:
|
||||||
if sptk_dict[e] > sptk_dict[emo]:
|
if sptk_dict[e] > sptk_dict[emo]:
|
||||||
emo = e
|
emo = e
|
||||||
for e in event_dict:
|
for e in event_dict:
|
||||||
if sptk_dict[e] > 0:
|
if sptk_dict[e] > 0:
|
||||||
s = event_dict[e] + s
|
s = event_dict[e] + s
|
||||||
s = s + emo_dict[emo]
|
s = s + emo_dict[emo]
|
||||||
|
|
||||||
|
for emoji in emo_set.union(event_set):
|
||||||
|
s = s.replace(" " + emoji, emoji)
|
||||||
|
s = s.replace(emoji + " ", emoji)
|
||||||
|
return s.strip()
|
||||||
|
|
||||||
for emoji in emo_set.union(event_set):
|
|
||||||
s = s.replace(" " + emoji, emoji)
|
|
||||||
s = s.replace(emoji + " ", emoji)
|
|
||||||
return s.strip()
|
|
||||||
|
|
||||||
def rich_transcription_postprocess(s):
|
def rich_transcription_postprocess(s):
|
||||||
def get_emo(s):
|
def get_emo(s):
|
||||||
return s[-1] if s[-1] in emo_set else None
|
return s[-1] if s[-1] in emo_set else None
|
||||||
def get_event(s):
|
|
||||||
return s[0] if s[0] in event_set else None
|
|
||||||
|
|
||||||
s = s.replace("<|nospeech|><|Event_UNK|>", "❓")
|
def get_event(s):
|
||||||
for lang in lang_dict:
|
return s[0] if s[0] in event_set else None
|
||||||
s = s.replace(lang, "<|lang|>")
|
|
||||||
s_list = [format_str_v2(s_i).strip(" ") for s_i in s.split("<|lang|>")]
|
s = s.replace("<|nospeech|><|Event_UNK|>", "❓")
|
||||||
new_s = " " + s_list[0]
|
for lang in lang_dict:
|
||||||
cur_ent_event = get_event(new_s)
|
s = s.replace(lang, "<|lang|>")
|
||||||
for i in range(1, len(s_list)):
|
s_list = [format_str_v2(s_i).strip(" ") for s_i in s.split("<|lang|>")]
|
||||||
if len(s_list[i]) == 0:
|
new_s = " " + s_list[0]
|
||||||
continue
|
cur_ent_event = get_event(new_s)
|
||||||
if get_event(s_list[i]) == cur_ent_event and get_event(s_list[i]) != None:
|
for i in range(1, len(s_list)):
|
||||||
s_list[i] = s_list[i][1:]
|
if len(s_list[i]) == 0:
|
||||||
#else:
|
continue
|
||||||
cur_ent_event = get_event(s_list[i])
|
if get_event(s_list[i]) == cur_ent_event and get_event(s_list[i]) != None:
|
||||||
if get_emo(s_list[i]) != None and get_emo(s_list[i]) == get_emo(new_s):
|
s_list[i] = s_list[i][1:]
|
||||||
new_s = new_s[:-1]
|
# else:
|
||||||
new_s += s_list[i].strip().lstrip()
|
cur_ent_event = get_event(s_list[i])
|
||||||
new_s = new_s.replace("The.", " ")
|
if get_emo(s_list[i]) != None and get_emo(s_list[i]) == get_emo(new_s):
|
||||||
return new_s.strip()
|
new_s = new_s[:-1]
|
||||||
|
new_s += s_list[i].strip().lstrip()
|
||||||
|
new_s = new_s.replace("The.", " ")
|
||||||
|
return new_s.strip()
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
1.1.10
|
1.1.11
|
||||||
Loading…
Reference in New Issue
Block a user