MCPcopy Create free account
hub / github.com/modelscope/FunASR / smooth

Function smooth

funasr/utils/speaker_utils.py:210–233  ·  view source on GitHub ↗

Smooth. Args: res: TODO. mindur: TODO.

(res, mindur=1)

Source from the content-addressed store, hash-verified

208
209
210def smooth(res, mindur=1):
211 # short segments are assigned to nearest speakers.
212 """Smooth.
213
214 Args:
215 res: TODO.
216 mindur: TODO.
217 """
218 for i in range(len(res)):
219 res[i][0] = round(res[i][0], 2)
220 res[i][1] = round(res[i][1], 2)
221 if res[i][1] - res[i][0] < mindur:
222 if i == 0:
223 res[i][2] = res[i + 1][2]
224 elif i == len(res) - 1:
225 res[i][2] = res[i - 1][2]
226 elif res[i][0] - res[i - 1][1] <= res[i + 1][0] - res[i][1]:
227 res[i][2] = res[i - 1][2]
228 else:
229 res[i][2] = res[i + 1][2]
230 # merge the speakers
231 res = merge_seque(res)
232
233 return res
234
235
236def distribute_spk(sentence_list, sd_time_list):

Callers 1

postprocessFunction · 0.70

Calls 1

merge_sequeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…