shiveshnavin commited on
Commit
6a87eec
·
1 Parent(s): 57bde2a

Fix word disconnections

Browse files
server-plugins/generate-captions.js CHANGED
@@ -120,11 +120,16 @@ export class CaptionPlugin extends Plugin {
120
  // Calculate positioning for centering
121
  const posTag = sideMargin > 0 ? `{\\an2\\pos(${videoWidth / 2},${videoHeight - translateY})}` : '';
122
 
 
 
 
 
123
  // For each word in the group, create an event with highlighting
 
124
  for (let wordIdx = 0; wordIdx < wordGroup.length; wordIdx++) {
125
  const wordObj = wordGroup[wordIdx];
126
  const wordStart = wordObj.start;
127
- const wordEnd = wordObj.end;
128
 
129
  // Build the caption text with highlighting
130
  const captionParts = wordGroup.map((w, idx) => {
@@ -139,7 +144,8 @@ export class CaptionPlugin extends Plugin {
139
 
140
  const captionText = tiltTag + posTag + captionParts.join(' ');
141
 
142
- // Write dialogue line
 
143
  output.write(`Dialogue: 0,${formatTimestampASS(wordStart)},${formatTimestampASS(wordEnd)},Default,,0,0,0,,${captionText}\n`);
144
  }
145
 
 
120
  // Calculate positioning for centering
121
  const posTag = sideMargin > 0 ? `{\\an2\\pos(${videoWidth / 2},${videoHeight - translateY})}` : '';
122
 
123
+ // Get the full group duration (from first word start to last word end)
124
+ const groupStart = wordGroup[0].start;
125
+ const groupEnd = wordGroup[wordGroup.length - 1].end;
126
+
127
  // For each word in the group, create an event with highlighting
128
+ // Use the FULL GROUP duration for each event to ensure no gaps
129
  for (let wordIdx = 0; wordIdx < wordGroup.length; wordIdx++) {
130
  const wordObj = wordGroup[wordIdx];
131
  const wordStart = wordObj.start;
132
+ const wordEnd = wordIdx < wordGroup.length - 1 ? wordGroup[wordIdx + 1].start : wordObj.end;
133
 
134
  // Build the caption text with highlighting
135
  const captionParts = wordGroup.map((w, idx) => {
 
144
 
145
  const captionText = tiltTag + posTag + captionParts.join(' ');
146
 
147
+ // Write dialogue line with timing from current word start to next word start (or group end)
148
+ // This ensures continuous display with no gaps between words
149
  output.write(`Dialogue: 0,${formatTimestampASS(wordStart)},${formatTimestampASS(wordEnd)},Default,,0,0,0,,${captionText}\n`);
150
  }
151