MCPcopy Create free account
hub / github.com/ASLP-lab/OSUM / get_frames_timestamp

Function get_frames_timestamp

OSUM/wenet/bin/alignment.py:55–85  ·  view source on GitHub ↗
(alignment,
                         prob,
                         blank_thres=0.999,
                         thres=0.0000000001)

Source from the content-addressed store, hash-verified

53
54
55def get_frames_timestamp(alignment,
56 prob,
57 blank_thres=0.999,
58 thres=0.0000000001):
59 # convert alignment to a praat format, which is a doing phonetics
60 # by computer and helps analyzing alignment
61 timestamp = []
62 # get frames level duration for each token
63 start = 0
64 end = 0
65 local_start = 0
66 while end < len(alignment):
67 while end < len(alignment) and alignment[end] == 0:
68 end += 1
69 if end == len(alignment):
70 timestamp[-1] += alignment[start:]
71 break
72 end += 1
73 while end < len(alignment) and alignment[end - 1] == alignment[end]:
74 end += 1
75 local_start = end - 1
76 # find the possible front border for current token
77 while local_start >= start and (
78 prob[local_start][0] < math.log(blank_thres)
79 or prob[local_start][alignment[end - 1]] > math.log(thres)):
80 alignment[local_start] = alignment[end - 1]
81 local_start -= 1
82 cur_alignment = alignment[start:end]
83 timestamp.append(cur_alignment)
84 start = end
85 return timestamp
86
87
88def get_labformat(timestamp, subsample):

Callers 1

alignment.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected