MCPcopy
hub / github.com/CapSoftware/Cap / transcribeVideoWorkflow

Function transcribeVideoWorkflow

apps/web/workflows/transcribe.ts:53–96  ·  view source on GitHub ↗
(
	payload: TranscribeWorkflowPayload,
)

Source from the content-addressed store, hash-verified

51}
52
53export async function transcribeVideoWorkflow(
54 payload: TranscribeWorkflowPayload,
55) {
56 "use workflow";
57
58 const { videoId, userId, aiGenerationEnabled } = payload;
59
60 const videoData = await validateVideo(videoId);
61
62 if (videoData.transcriptionDisabled) {
63 await markSkipped(videoId);
64 return { success: true, message: "Transcription disabled - skipped" };
65 }
66
67 try {
68 const audioUrl = await extractAudio(videoId, userId, videoData.video);
69
70 if (!audioUrl) {
71 await markNoAudio(videoId);
72 return {
73 success: true,
74 message: "Video has no audio track - skipped transcription",
75 };
76 }
77
78 const [transcription] = await Promise.all([
79 transcribeWithDeepgram(audioUrl, videoData.aiGenerationLanguage),
80 ]);
81
82 await saveTranscription(videoId, userId, videoData.video, transcription);
83 } catch (error) {
84 await markError(videoId);
85 await cleanupTempAudio(videoId, userId, videoData.video);
86 throw error;
87 }
88
89 await cleanupTempAudio(videoId, userId, videoData.video);
90
91 if (aiGenerationEnabled) {
92 await queueAiGeneration(videoId, userId);
93 }
94
95 return { success: true, message: "Transcription completed successfully" };
96}
97
98async function validateVideo(videoId: string): Promise<VideoData> {
99 "use step";

Callers

nothing calls this directly

Calls 9

validateVideoFunction · 0.85
markNoAudioFunction · 0.85
transcribeWithDeepgramFunction · 0.85
saveTranscriptionFunction · 0.85
markErrorFunction · 0.85
cleanupTempAudioFunction · 0.85
queueAiGenerationFunction · 0.85
markSkippedFunction · 0.70
extractAudioFunction · 0.70

Tested by

no test coverage detected