Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Handle videos with no audio in transcription workflow

Richie McIlroyf9d738d2c391
diff --git a/apps/web/workflows/transcribe.ts b/apps/web/workflows/transcribe.ts
index 0990d4412..72d120578 100644
--- a/apps/web/workflows/transcribe.ts
+++ b/apps/web/workflows/transcribe.ts
@@ -43,6 +43,14 @@ export async function transcribeVideoWorkflow(
const audioUrl = await extractAudio(videoId, userId, videoData.bucketId);
+ if (!audioUrl) {
+ await markNoAudio(videoId);
+ return {
+ success: true,
+ message: "Video has no audio track - skipped transcription",
+ };
+ }
+
const transcription = await transcribeWithDeepgram(audioUrl);
await saveTranscription(videoId, userId, videoData.bucketId, transcription);
@@ -111,6 +119,16 @@ async function markSkipped(videoId: string): Promise<void> {
.where(eq(videos.id, videoId as Video.VideoId));
}
+async function markNoAudio(videoId: string): Promise<void> {
+ "use step";
+
+ console.log(`[transcribe-workflow] Video ${videoId} has no audio track`);
+ await db()
+ .update(videos)
+ .set({ transcriptionStatus: "NO_AUDIO" })
+ .where(eq(videos.id, videoId as Video.VideoId));
+}
+
async function extractAudio(
videoId: string,
userId: string,
@@ -163,15 +181,9 @@ async function extractAudio(
}
}
-async function transcribeWithDeepgram(
- audioUrl: string | null,
-): Promise<string> {
+async function transcribeWithDeepgram(audioUrl: string): Promise<string> {
"use step";
- if (!audioUrl) {
- return "WEBVTT\n\n";
- }
-
console.log("[transcribe-workflow] Calling Deepgram API");
const deepgram = createClient(serverEnv().DEEPGRAM_API_KEY as string);
diff --git a/packages/database/schema.ts b/packages/database/schema.ts
index 14a2e9685..85f03f25b 100644
--- a/packages/database/schema.ts
+++ b/packages/database/schema.ts
@@ -312,7 +312,7 @@ export const videos = mysqlTable(
disableComments?: boolean;
}>(),
transcriptionStatus: varchar("transcriptionStatus", { length: 255 }).$type<
- "PROCESSING" | "COMPLETE" | "ERROR" | "SKIPPED"
+ "PROCESSING" | "COMPLETE" | "ERROR" | "SKIPPED" | "NO_AUDIO"
>(),
source: json("source")
.$type<