mazesmazes commited on
Commit
f3ed069
·
verified ·
1 Parent(s): 12cc77c

Update custom model files, README, and requirements

Browse files
Files changed (1) hide show
  1. alignment.py +2 -18
alignment.py CHANGED
@@ -130,7 +130,7 @@ class ForcedAligner:
130
  token_frames[j - 1].insert(0, 0)
131
  j -= 1
132
 
133
- # Convert to spans with sub-frame interpolation
134
  token_spans: list[tuple[int, float, float]] = []
135
  for token_idx, frames in enumerate(token_frames):
136
  if not frames:
@@ -146,23 +146,7 @@ class ForcedAligner:
146
  peak_idx = int(torch.argmax(frame_probs).item())
147
  peak_frame = frames[peak_idx]
148
 
149
- # Sub-frame interpolation using quadratic fit around peak
150
- if len(frames) >= 3 and 0 < peak_idx < len(frames) - 1:
151
- y0 = frame_probs[peak_idx - 1].item()
152
- y1 = frame_probs[peak_idx].item()
153
- y2 = frame_probs[peak_idx + 1].item()
154
-
155
- denom = y0 - 2 * y1 + y2
156
- if abs(denom) > 1e-10:
157
- offset = 0.5 * (y0 - y2) / denom
158
- offset = max(-0.5, min(0.5, offset))
159
- else:
160
- offset = 0.0
161
- refined_frame = peak_frame + offset
162
- else:
163
- refined_frame = float(peak_frame)
164
-
165
- token_spans.append((token_id, refined_frame, refined_frame + 1.0))
166
 
167
  return token_spans
168
 
 
130
  token_frames[j - 1].insert(0, 0)
131
  j -= 1
132
 
133
+ # Convert to spans
134
  token_spans: list[tuple[int, float, float]] = []
135
  for token_idx, frames in enumerate(token_frames):
136
  if not frames:
 
146
  peak_idx = int(torch.argmax(frame_probs).item())
147
  peak_frame = frames[peak_idx]
148
 
149
+ token_spans.append((token_id, float(peak_frame), float(peak_frame) + 1.0))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
  return token_spans
152