vidistill 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +41 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1604,14 +1604,22 @@ function replaceNamesInText(text4, mapping) {
|
|
|
1604
1604
|
const entries = Object.entries(mapping).filter(([key, value]) => key !== value && !/^SPEAKER_\d+$/.test(key)).sort((a, b) => b[0].length - a[0].length);
|
|
1605
1605
|
if (entries.length === 0) return text4;
|
|
1606
1606
|
let result = text4;
|
|
1607
|
+
const placeholders = /* @__PURE__ */ new Map();
|
|
1608
|
+
let idx = 0;
|
|
1607
1609
|
for (const [key, value] of entries) {
|
|
1610
|
+
const placeholder = `\0PH${idx}\0`;
|
|
1611
|
+
placeholders.set(placeholder, value);
|
|
1608
1612
|
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1609
1613
|
const re = new RegExp(`\\b${escaped}\\b`, "g");
|
|
1610
|
-
result = result.replace(re,
|
|
1614
|
+
result = result.replace(re, placeholder);
|
|
1615
|
+
idx++;
|
|
1616
|
+
}
|
|
1617
|
+
for (const [placeholder, value] of placeholders) {
|
|
1618
|
+
result = result.replaceAll(placeholder, value);
|
|
1611
1619
|
}
|
|
1612
1620
|
return result;
|
|
1613
1621
|
}
|
|
1614
|
-
function buildExpandedMapping(segments, speakerMapping) {
|
|
1622
|
+
function buildExpandedMapping(segments, speakerMapping, peopleExtraction) {
|
|
1615
1623
|
const expanded = { ...speakerMapping };
|
|
1616
1624
|
for (const seg of segments) {
|
|
1617
1625
|
if (seg.pass1 == null) continue;
|
|
@@ -1640,6 +1648,19 @@ function buildExpandedMapping(segments, speakerMapping) {
|
|
|
1640
1648
|
}
|
|
1641
1649
|
}
|
|
1642
1650
|
}
|
|
1651
|
+
if (peopleExtraction?.participants != null) {
|
|
1652
|
+
for (const p of peopleExtraction.participants) {
|
|
1653
|
+
if (!p.name || expanded[p.name] != null) continue;
|
|
1654
|
+
for (const [key, value] of Object.entries(expanded)) {
|
|
1655
|
+
if (/^SPEAKER_\d+$/.test(key)) continue;
|
|
1656
|
+
if (key === value) continue;
|
|
1657
|
+
if (p.name !== key && p.name.includes(key)) {
|
|
1658
|
+
expanded[p.name] = value;
|
|
1659
|
+
break;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1643
1664
|
return expanded;
|
|
1644
1665
|
}
|
|
1645
1666
|
async function readJsonFile(filePath) {
|
|
@@ -3482,37 +3503,30 @@ function writeGuide(params) {
|
|
|
3482
3503
|
}
|
|
3483
3504
|
|
|
3484
3505
|
// src/output/transcript.ts
|
|
3485
|
-
var PAUSE_THRESHOLD_SECONDS = 1.5;
|
|
3486
|
-
function applyEmphasis(text4, emphasisWords) {
|
|
3487
|
-
if (emphasisWords == null || emphasisWords.length === 0) return text4;
|
|
3488
|
-
let result = text4;
|
|
3489
|
-
for (const word of emphasisWords) {
|
|
3490
|
-
const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3491
|
-
const re = new RegExp(`(?<![\\w*])${escaped}(?![\\w*])`, "gi");
|
|
3492
|
-
result = result.replace(re, `**$&**`);
|
|
3493
|
-
}
|
|
3494
|
-
return result;
|
|
3495
|
-
}
|
|
3496
3506
|
function renderEntry(entry, speakerMapping) {
|
|
3497
|
-
const emphasized = applyEmphasis(entry.text, entry.emphasis_words);
|
|
3498
|
-
const pause = entry.pause_after_seconds != null && entry.pause_after_seconds >= PAUSE_THRESHOLD_SECONDS ? ` _(pause ${entry.pause_after_seconds.toFixed(1)}s)_` : "";
|
|
3499
3507
|
const speaker = applySpeakerMapping(entry.speaker, speakerMapping);
|
|
3500
|
-
return `**[${entry.timestamp}]** **${speaker}:** ${
|
|
3508
|
+
return `**[${entry.timestamp}]** **${speaker}:** ${entry.text}`;
|
|
3509
|
+
}
|
|
3510
|
+
function parseEndTime(timeRange) {
|
|
3511
|
+
const parts = timeRange.split("-");
|
|
3512
|
+
if (parts.length < 2) return Infinity;
|
|
3513
|
+
const endStr = parts[parts.length - 1].trim();
|
|
3514
|
+
const seconds = parseTimestamp(endStr);
|
|
3515
|
+
return seconds > 0 ? seconds : Infinity;
|
|
3501
3516
|
}
|
|
3502
3517
|
function renderPass1(pass1, speakerMapping) {
|
|
3503
3518
|
const lines = [];
|
|
3504
3519
|
lines.push(`### Segment ${pass1.segment_index + 1} \u2014 ${pass1.time_range}`);
|
|
3505
3520
|
lines.push("");
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
if (pass1.transcript_entries.length === 0) {
|
|
3521
|
+
const endTime = parseEndTime(pass1.time_range);
|
|
3522
|
+
const validEntries = pass1.transcript_entries.filter((entry) => {
|
|
3523
|
+
const entryTime = parseTimestamp(entry.timestamp);
|
|
3524
|
+
return entryTime <= endTime;
|
|
3525
|
+
});
|
|
3526
|
+
if (validEntries.length === 0) {
|
|
3513
3527
|
lines.push("_No transcript entries for this segment._");
|
|
3514
3528
|
} else {
|
|
3515
|
-
for (const entry of
|
|
3529
|
+
for (const entry of validEntries) {
|
|
3516
3530
|
lines.push(renderEntry(entry, speakerMapping));
|
|
3517
3531
|
}
|
|
3518
3532
|
}
|
|
@@ -4681,7 +4695,7 @@ async function generateOutput(params) {
|
|
|
4681
4695
|
const filesGenerated = [];
|
|
4682
4696
|
const errors = [];
|
|
4683
4697
|
const filesToGenerate = resolveFilesToGenerate(params);
|
|
4684
|
-
const expandedMapping = speakerMapping ? buildExpandedMapping(pipelineResult.segments, speakerMapping) : void 0;
|
|
4698
|
+
const expandedMapping = speakerMapping ? buildExpandedMapping(pipelineResult.segments, speakerMapping, pipelineResult.peopleExtraction) : void 0;
|
|
4685
4699
|
async function writeOutputFile(filename, content) {
|
|
4686
4700
|
const fullPath = join3(finalOutputDir, filename);
|
|
4687
4701
|
const dir = dirname(fullPath);
|
|
@@ -4875,7 +4889,7 @@ async function reRenderWithSpeakerMapping(params) {
|
|
|
4875
4889
|
await writeFile(fullPath, content, "utf8");
|
|
4876
4890
|
filesWritten.push(filename);
|
|
4877
4891
|
}
|
|
4878
|
-
const expandedMapping = buildExpandedMapping(pipelineResult.segments, speakerMapping);
|
|
4892
|
+
const expandedMapping = buildExpandedMapping(pipelineResult.segments, speakerMapping, pipelineResult.peopleExtraction);
|
|
4879
4893
|
const filesToReRender = new Set(filesGenerated.filter((f) => !f.startsWith("raw/")));
|
|
4880
4894
|
if (filesToReRender.has("transcript.md")) {
|
|
4881
4895
|
try {
|
|
@@ -5638,7 +5652,7 @@ async function run2(args) {
|
|
|
5638
5652
|
}
|
|
5639
5653
|
|
|
5640
5654
|
// src/cli/index.ts
|
|
5641
|
-
var version = "0.5.
|
|
5655
|
+
var version = "0.5.3";
|
|
5642
5656
|
var DEFAULT_OUTPUT = "./vidistill-output/";
|
|
5643
5657
|
var SUBCOMMANDS = {
|
|
5644
5658
|
mcp: run,
|
package/package.json
CHANGED