MCPcopy Create free account
hub / github.com/FunAudioLLM/SenseVoice / format_str_v3

Function format_str_v3

webui.py:116–139  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

114 return s.strip()
115
116def format_str_v3(s):
117 def get_emo(s):
118 return s[-1] if s[-1] in emo_set else None
119 def get_event(s):
120 return s[0] if s[0] in event_set else None
121
122 s = s.replace("<|nospeech|><|Event_UNK|>", "❓")
123 for lang in lang_dict:
124 s = s.replace(lang, "<|lang|>")
125 s_list = [format_str_v2(s_i).strip(" ") for s_i in s.split("<|lang|>")]
126 new_s = " " + s_list[0]
127 cur_ent_event = get_event(new_s)
128 for i in range(1, len(s_list)):
129 if len(s_list[i]) == 0:
130 continue
131 if get_event(s_list[i]) == cur_ent_event and get_event(s_list[i]) != None:
132 s_list[i] = s_list[i][1:]
133 #else:
134 cur_ent_event = get_event(s_list[i])
135 if get_emo(s_list[i]) != None and get_emo(s_list[i]) == get_emo(new_s):
136 new_s = new_s[:-1]
137 new_s += s_list[i].strip().lstrip()
138 new_s = new_s.replace("The.", " ")
139 return new_s.strip()
140
141def model_inference(input_wav, language, fs=16000):
142 # task_abbr = {"Speech Recognition": "ASR", "Rich Text Transcription": ("ASR", "AED", "SER")}

Callers 1

model_inferenceFunction · 0.85

Calls 3

format_str_v2Function · 0.85
get_eventFunction · 0.85
get_emoFunction · 0.85

Tested by

no test coverage detected