Skip to content

Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.

Address AssemblyAI review feedback

Teethat Kamsaib2d9d31b4574
diff --git a/backend/cli.py b/backend/cli.py
index 5662c7c..3205496 100644
--- a/backend/cli.py
+++ b/backend/cli.py
@@ -3340,7 +3340,7 @@ def main():
proc.add_argument("-o", "--output", help="Output directory (default: ./clips)")
proc.add_argument("-p", "--preset", help="Load a saved preset")
proc.add_argument("--engine", choices=["whisper-py", "whispercpp", "assemblyai"], help="Transcription engine (default: whisper-py; whispercpp is local; assemblyai uses ASSEMBLYAI_API_KEY)")
- proc.add_argument("--assemblyai-api-key", help="AssemblyAI API key for --engine assemblyai")
+ proc.add_argument("--assemblyai-api-key", help="AssemblyAI API key for --engine assemblyai. Prefer ASSEMBLYAI_API_KEY; command-line secrets can appear in process listings.")
proc.add_argument("--fast", action="store_true", help="Draft mode: tiny Whisper, heuristic selection, center crop, low quality")
proc.add_argument("--thumbnails", dest="thumbnails", action="store_true", default=None, help="Force thumbnail generation on")
proc.add_argument("--no-thumbnails", dest="thumbnails", action="store_false", help="Skip thumbnail generation")
@@ -3367,7 +3367,7 @@ def main():
studio.add_argument("--paragraph", help="Find the fragment by matching this text in the transcript")
studio.add_argument("--language", help="Transcription language (e.g. es). Auto-detect if omitted.")
studio.add_argument("--engine", choices=["whisper-py", "whispercpp", "assemblyai"], help="Transcription engine")
- studio.add_argument("--assemblyai-api-key", help="AssemblyAI API key for --engine assemblyai")
+ studio.add_argument("--assemblyai-api-key", help="AssemblyAI API key for --engine assemblyai. Prefer ASSEMBLYAI_API_KEY; command-line secrets can appear in process listings.")
studio.add_argument("--caption-style", choices=["hormozi", "karaoke", "subtle", "branded"], default="hormozi")
studio.add_argument("--crop", choices=["center", "face", "speaker", "speaker-hardcut"], default="face")
studio.add_argument("-o", "--output", help="Final output path")
diff --git a/install.ps1 b/install.ps1
index c4ddffa..50a8608 100644
--- a/install.ps1
+++ b/install.ps1
@@ -50,7 +50,11 @@ public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wP
if ($Uninstall) {
Write-Host "Uninstalling podcli..."
- $targets = @($homeDir)
+ if ($Purge) {
+ $targets = @($homeDir)
+ } else {
+ $targets = @($binDir, (Join-Path $homeDir 'runtime'), (Join-Path $homeDir 'models'), (Join-Path $homeDir 'tools'))
+ }
foreach ($p in $targets) {
if (Test-Path $p) {
try {
@@ -71,7 +75,11 @@ if ($Uninstall) {
Write-Host " removed from user PATH (restart your terminal)"
}
}
- Write-Host " removed managed data."
+ if ($Purge) {
+ Write-Host " removed podcli and user data."
+ } else {
+ Write-Host " removed podcli runtime files. User data preserved; pass -Purge to remove it."
+ }
exit 0
}
diff --git a/src/handlers/transcribe.handler.ts b/src/handlers/transcribe.handler.ts
index bcae77b..1d05949 100644
--- a/src/handlers/transcribe.handler.ts
+++ b/src/handlers/transcribe.handler.ts
@@ -9,6 +9,7 @@ const cache = new TranscriptCache();
export interface TranscribeInput {
file_path: string;
model_size?: "tiny" | "base" | "small" | "medium" | "large";
+ engine?: "whisper-py" | "whispercpp" | "assemblyai";
language?: string;
enable_diarization?: boolean;
num_speakers?: number;
@@ -45,6 +46,11 @@ export const transcribeToolDef = {
type: "string",
description: "ISO language code (e.g. 'en'). Leave empty for auto-detect.",
},
+ engine: {
+ type: "string",
+ enum: ["whisper-py", "whispercpp", "assemblyai"],
+ description: "Transcription engine. Default: whisper-py.",
+ },
enable_diarization: {
type: "boolean",
description:
@@ -65,25 +71,27 @@ export const transcribeToolDef = {
export async function handleTranscribe(input: TranscribeInput): Promise<string> {
const filePath = input.file_path;
const modelSize = input.model_size ?? "base";
+ const engine = input.engine;
const language = input.language;
const enableDiarization = input.enable_diarization !== false; // default true
const numSpeakers = input.num_speakers;
// Check cache first
- const cached = await cache.get(filePath);
+ const cached = await cache.get(filePath, engine);
if (cached) {
+ const packedEngine = cached.engine ?? engine;
// Backfill packed view if this cache predates auto-packing.
- let packed = await cache.getPackedMarkdown(filePath);
+ let packed = await cache.getPackedMarkdown(filePath, packedEngine);
if (!packed) {
try {
- const cacheHash = await cache.getFileHash(filePath);
+ const cacheHash = await cache.getFileHashForEngine(filePath, packedEngine);
await executor.execute("pack_transcript", {
transcript: cached,
cache_hash: cacheHash,
source_label: basename(filePath),
file_path: filePath,
});
- packed = await cache.getPackedMarkdown(filePath);
+ packed = await cache.getPackedMarkdown(filePath, packedEngine);
} catch {
// Non-fatal — caller still gets metadata
}
@@ -95,6 +103,7 @@ export async function handleTranscribe(input: TranscribeInput): Promise<string>
const result = await executor.execute<TranscriptResult>("transcribe", {
file_path: filePath,
model_size: modelSize,
+ engine,
language,
enable_diarization: enableDiarization,
num_speakers: numSpeakers,
@@ -106,8 +115,8 @@ export async function handleTranscribe(input: TranscribeInput): Promise<string>
const data = result.data;
// Cache the raw result
- await cache.set(filePath, data);
- const packed = await cache.getPackedMarkdown(filePath);
+ await cache.set(filePath, data, engine);
+ const packed = await cache.getPackedMarkdown(filePath, data.engine ?? engine);
return JSON.stringify({ cached: false, packed_ready: !!packed, ...formatResult(data) });
}
@@ -153,6 +162,10 @@ export const transcribeStartToolDef = {
default: "base",
},
language: { type: "string" },
+ engine: {
+ type: "string",
+ enum: ["whisper-py", "whispercpp", "assemblyai"],
+ },
enable_diarization: { type: "boolean", default: true },
num_speakers: { type: "number" },
},
@@ -168,6 +181,7 @@ export async function handleTranscribeStart(input: TranscribeInput): Promise<str
body: JSON.stringify({
file_path: input.file_path,
model_size: input.model_size ?? "base",
+ engine: input.engine,
language: input.language,
enable_diarization: input.enable_diarization !== false,
num_speakers: input.num_speakers,
diff --git a/src/models/index.ts b/src/models/index.ts
index a7393a7..ebc424f 100644
--- a/src/models/index.ts
+++ b/src/models/index.ts
@@ -65,6 +65,7 @@ export interface TranscriptResult {
language: string;
speakers: SpeakerSummary;
speaker_segments: SpeakerSegment[];
+ engine?: string;
}
// === Clip Models ===
diff --git a/src/server.ts b/src/server.ts
index 6662326..e6b11d3 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -241,6 +241,10 @@ export function createServer(): McpServer {
.optional()
.default("base")
.describe("Whisper model size"),
+ engine: z
+ .enum(["whisper-py", "whispercpp", "assemblyai"])
+ .optional()
+ .describe("Transcription engine"),
language: z.string().optional().describe("ISO language code"),
enable_diarization: z
.boolean()
@@ -257,6 +261,7 @@ export function createServer(): McpServer {
async ({
file_path,
model_size,
+ engine,
language,
enable_diarization,
num_speakers,
@@ -265,6 +270,7 @@ export function createServer(): McpServer {
const result = await handleTranscribe({
file_path,
model_size,
+ engine,
language,
enable_diarization,
num_speakers,
@@ -274,7 +280,7 @@ export function createServer(): McpServer {
// on-disk cache — NOT the trimmed MCP response. Without words in UI
// state, downstream batch_create_clips can't burn captions.
try {
- const cached = await transcriptCache.get(file_path);
+ const cached = await transcriptCache.get(file_path, engine);
if (cached) {
await uiPing({
videoPath: file_path,
@@ -314,6 +320,7 @@ export function createServer(): McpServer {
.optional()
.default("base"),
language: z.string().optional(),
+ engine: z.enum(["whisper-py", "whispercpp", "assemblyai"]).optional(),
enable_diarization: z.boolean().optional().default(true),
num_speakers: z.number().optional(),
},
@@ -1307,7 +1314,10 @@ export function createServer(): McpServer {
// Auto-generated during transcription — see backend/services/transcript_packer.py.
let packed: string | null = null;
if (state.videoPath) {
- packed = await transcriptCache.getPackedMarkdown(state.videoPath);
+ packed = await transcriptCache.getPackedMarkdown(
+ state.videoPath,
+ state.transcript?.engine,
+ );
}
if (!packed && state.rawTranscriptText) {
packed = await transcriptCache.getPackedMarkdownFromText(
diff --git a/src/services/transcript-cache.test.ts b/src/services/transcript-cache.test.ts
index 0c16820..2ad11b8 100644
--- a/src/services/transcript-cache.test.ts
+++ b/src/services/transcript-cache.test.ts
@@ -69,6 +69,15 @@ describe("TranscriptCache", () => {
expect(hashA).toBe(hashB);
});
+ it("reads packed markdown with the engine suffix", async () => {
+ const file = makeFakeVideo("assemblyai.mp4", "same media");
+ const hash = await cache.getFileHashForEngine(file, "assemblyai");
+ mkdirSync(join(tmp, "packed"), { recursive: true });
+ writeFileSync(join(tmp, "packed", `${hash}.md`), "# Packed AssemblyAI");
+ expect(await cache.getPackedMarkdown(file, "assemblyai")).toBe("# Packed AssemblyAI");
+ expect(await cache.getPackedMarkdown(file)).toBeNull();
+ });
+
it("get returns null when the cache file is corrupt", async () => {
const file = makeFakeVideo("corrupt-source.mp4", "any content");
const hash = await cache.getFileHash(file);
diff --git a/src/services/transcript-cache.ts b/src/services/transcript-cache.ts
index 9f65f6e..345a06e 100644
--- a/src/services/transcript-cache.ts
+++ b/src/services/transcript-cache.ts
@@ -64,6 +64,10 @@ export class TranscriptCache {
});
}
+ async getFileHashForEngine(filePath: string, engine?: string): Promise<string> {
+ return `${await this.getFileHash(filePath)}${this.engineSuffix(engine)}`;
+ }
+
private engineSuffix(engine?: string): string {
const value = (engine ?? "").trim().toLowerCase();
if (["whispercpp", "whisper-cpp", "whisper.cpp", "cpp"].includes(value)) {
@@ -103,7 +107,7 @@ export class TranscriptCache {
*/
async getPackedMarkdown(filePath: string, engine?: string): Promise<string | null> {
try {
- const hash = `${await this.getFileHash(filePath)}${this.engineSuffix(engine)}`;
+ const hash = await this.getFileHashForEngine(filePath, engine);
return await this.readPackedByHash(hash);
} catch {
return null;
diff --git a/src/ui/web-server.ts b/src/ui/web-server.ts
index e827cd4..6f90c11 100644
--- a/src/ui/web-server.ts
+++ b/src/ui/web-server.ts
@@ -20,7 +20,7 @@ import {
chmodSync,
realpathSync,
} from "fs";
-import { mkdir, readdir, rm, unlink } from "fs/promises";
+import { mkdir, readdir, unlink } from "fs/promises";
import path from "path";
import { join, dirname, basename, extname, resolve } from "path";
import { execSync, spawn } from "child_process";
@@ -338,9 +338,6 @@ app.use(express.static(publicDir));
// File upload config
const uploadDir = join(paths.working, "uploads");
-const cachedMediaExtensions = new Set([".mp4", ".mov", ".mkv", ".webm", ".mp3", ".wav", ".m4a"]);
-const transcriptCacheExtensions = new Set([".json"]);
-const packedTranscriptExtensions = new Set([".md"]);
const upload = multer({
storage: multer.diskStorage({
destination: async (_req, _file, cb) => {
@@ -380,19 +377,6 @@ const upload = multer({
},
});
-async function clearCacheFiles(dir: string, extensions: Set<string>): Promise<number> {
- if (!existsSync(dir)) return 0;
- const entries = await readdir(dir, { withFileTypes: true });
- let deleted = 0;
- for (const entry of entries) {
- if (!entry.isFile()) continue;
- if (!extensions.has(extname(entry.name).toLowerCase())) continue;
- await rm(join(dir, entry.name), { force: true });
- deleted += 1;
- }
- return deleted;
-}
-
function clearEpisodeSessionState(): void {
sessionTranscripts.clear();
allowedSourcePaths.clear();
@@ -484,7 +468,7 @@ async function validateDownloadUrl(rawUrl: unknown): Promise<string> {
// --- API Routes ---
/**
- * POST /api/session-cache/clear - Clear per-session uploads and transcript caches.
+ * POST /api/session-cache/clear - Clear in-memory UI state.
*/
app.post("/api/session-cache/clear", async (_req, res) => {
try {
@@ -496,13 +480,10 @@ app.post("/api/session-cache/clear", async (_req, res) => {
});
return;
}
- const uploads = await clearCacheFiles(uploadDir, cachedMediaExtensions);
- const transcripts = await clearCacheFiles(paths.transcripts, transcriptCacheExtensions);
- const packed = await clearCacheFiles(paths.packed, packedTranscriptExtensions);
clearEpisodeSessionState();
persistState();
broadcastSSE("state-sync", uiState);
- res.json({ ok: true, uploads, transcripts, packed });
+ res.json({ ok: true });
} catch (err) {
res.status(500).json({ error: `Failed to clear session cache: ${errMsg(err)}` });
}
@@ -860,6 +841,12 @@ app.post("/api/transcribe", async (req, res) => {
if (cached) {
const jobId = uuidv4();
sessionTranscripts.set(file_path, cached as unknown as ServerTranscript);
+ uiState.transcript = cached as unknown as typeof uiState.transcript;
+ uiState.videoPath = file_path;
+ uiState.filePath = file_path;
+ registerSourcePath(file_path);
+ uiState.lastUpdated = Date.now();
+ persistState();
res.json({
job_id: jobId,
status: "done",