Spaces:
Running
Running
Commit ·
3807db1
1
Parent(s): 63cb56d
Fix concat cleanup
Browse files
server-plugins/generate-captions.js
CHANGED
|
@@ -42,6 +42,7 @@ export class CaptionPlugin extends Plugin {
|
|
| 42 |
* @param {Object} options
|
| 43 |
* @param {string} options.captionFilePath - Path to input JSON caption file
|
| 44 |
* @param {string} options.outputFilePath - Path to output ASS file
|
|
|
|
| 45 |
* @param {number} [options.tiltDegrees=8] - Tilt angle in degrees (alternates between +/-)
|
| 46 |
* @param {number} [options.translateY=200] - Distance from bottom in pixels
|
| 47 |
* @param {number} [options.widthPercent=80] - Width percentage for text centering (0-100)
|
|
@@ -61,6 +62,7 @@ export class CaptionPlugin extends Plugin {
|
|
| 61 |
widthPercent = 80,
|
| 62 |
fontName = 'Impact',
|
| 63 |
fontSize = 72,
|
|
|
|
| 64 |
wordsPerGroup = 4,
|
| 65 |
videoWidth = 1920,
|
| 66 |
videoHeight = 1080,
|
|
@@ -82,6 +84,15 @@ export class CaptionPlugin extends Plugin {
|
|
| 82 |
throw new Error('No words found in caption file');
|
| 83 |
}
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
// Assign sentence indices to words
|
| 86 |
words = assignSentenceToWords(words, transcript);
|
| 87 |
|
|
|
|
| 42 |
* @param {Object} options
|
| 43 |
* @param {string} options.captionFilePath - Path to input JSON caption file
|
| 44 |
* @param {string} options.outputFilePath - Path to output ASS file
|
| 45 |
+
* @param {string} options.capitalize - capitalize the font. upper, full-upper, small, none
|
| 46 |
* @param {number} [options.tiltDegrees=8] - Tilt angle in degrees (alternates between +/-)
|
| 47 |
* @param {number} [options.translateY=200] - Distance from bottom in pixels
|
| 48 |
* @param {number} [options.widthPercent=80] - Width percentage for text centering (0-100)
|
|
|
|
| 62 |
widthPercent = 80,
|
| 63 |
fontName = 'Impact',
|
| 64 |
fontSize = 72,
|
| 65 |
+
capitalize = 'upper',
|
| 66 |
wordsPerGroup = 4,
|
| 67 |
videoWidth = 1920,
|
| 68 |
videoHeight = 1080,
|
|
|
|
| 84 |
throw new Error('No words found in caption file');
|
| 85 |
}
|
| 86 |
|
| 87 |
+
if (capitalize == 'full-upper') {
|
| 88 |
+
words = words.map(w => ({ ...w, word: w.word.toUpperCase() }));
|
| 89 |
+
}
|
| 90 |
+
else if (capitalize == 'upper') {
|
| 91 |
+
words = words.map(w => ({ ...w, word: w.word.charAt(0).toUpperCase() + w.word.slice(1) }));
|
| 92 |
+
}
|
| 93 |
+
else if (capitalize == 'small') {
|
| 94 |
+
words = words.map(w => ({ ...w, word: w.word.toLowerCase() }));
|
| 95 |
+
}
|
| 96 |
// Assign sentence indices to words
|
| 97 |
words = assignSentenceToWords(words, transcript);
|
| 98 |
|