Return reasons an alignment looks too low-quality to trust (empty = trust it). Used by --skip-sync-on-low-quality to decide whether to leave the subtitles unmodified rather than apply a probably-wrong shift. A negative score means the best alignment is anti-correlated; an implausibly la
(
best_score: float,
offset_seconds: float,
scale_factor: float,
*,
min_score: float,
max_offset_seconds: float,
max_framerate_deviation: float,
)
| 143 | |
| 144 | |
| 145 | def assess_alignment_quality( |
| 146 | best_score: float, |
| 147 | offset_seconds: float, |
| 148 | scale_factor: float, |
| 149 | *, |
| 150 | min_score: float, |
| 151 | max_offset_seconds: float, |
| 152 | max_framerate_deviation: float, |
| 153 | ) -> List[str]: |
| 154 | """Return reasons an alignment looks too low-quality to trust (empty = trust it). |
| 155 | |
| 156 | Used by --skip-sync-on-low-quality to decide whether to leave the subtitles |
| 157 | unmodified rather than apply a probably-wrong shift. A negative score means the |
| 158 | best alignment is anti-correlated; an implausibly large offset or framerate |
| 159 | scale suggests a spurious match. |
| 160 | """ |
| 161 | reasons: List[str] = [] |
| 162 | if best_score < min_score: |
| 163 | reasons.append("score %.1f < %.1f" % (best_score, min_score)) |
| 164 | if abs(offset_seconds) > max_offset_seconds: |
| 165 | reasons.append( |
| 166 | "|offset| %.1fs > %.1fs" % (abs(offset_seconds), max_offset_seconds) |
| 167 | ) |
| 168 | framerate_deviation = abs(scale_factor - 1.0) |
| 169 | if framerate_deviation > max_framerate_deviation: |
| 170 | reasons.append( |
| 171 | "framerate deviation %.3f > %.3f" |
| 172 | % (framerate_deviation, max_framerate_deviation) |
| 173 | ) |
| 174 | return reasons |
| 175 | |
| 176 | |
| 177 | def try_sync( |
no outgoing calls