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

Function transcribeVideo

apps/web/lib/transcribe.ts:27–168  ·  view source on GitHub ↗
(
	videoId: Video.VideoId,
	userId: string,
	aiGenerationEnabled = false,
)

Source from the content-addressed store, hash-verified

25};
26
27export async function transcribeVideo(
28 videoId: Video.VideoId,
29 userId: string,
30 aiGenerationEnabled = false,
31): Promise<TranscribeResult> {
32 if (!serverEnv().DEEPGRAM_API_KEY) {
33 return {
34 success: false,
35 message: "Missing necessary environment variables",
36 };
37 }
38
39 if (!userId || !videoId) {
40 return {
41 success: false,
42 message: "userId or videoId not supplied",
43 };
44 }
45
46 const query = await db()
47 .select({
48 video: videos,
49 settings: videos.settings,
50 orgSettings: organizations.settings,
51 })
52 .from(videos)
53 .leftJoin(organizations, eq(videos.orgId, organizations.id))
54 .where(eq(videos.id, videoId));
55
56 if (query.length === 0) {
57 return { success: false, message: "Video does not exist" };
58 }
59
60 const result = query[0];
61 if (!result || !result.video) {
62 return { success: false, message: "Video information is missing" };
63 }
64
65 const { video } = result;
66
67 if (!video) {
68 return { success: false, message: "Video information is missing" };
69 }
70
71 if (
72 video.settings?.disableTranscript ??
73 result.orgSettings?.disableTranscript
74 ) {
75 console.log(
76 `[transcribeVideo] Transcription disabled for video ${videoId}`,
77 );
78 try {
79 await db()
80 .update(videos)
81 .set({ transcriptionStatus: "SKIPPED" })
82 .where(eq(videos.id, videoId));
83 } catch (err) {
84 console.error(`[transcribeVideo] Failed to mark as skipped:`, err);

Callers 6

getVideoStatusFunction · 0.90
AuthorizedContentFunction · 0.90
EmbedContentFunction · 0.90
transcribe.test.tsFile · 0.90

Calls 5

serverEnvFunction · 0.90
dbFunction · 0.90
startFunction · 0.90
updateMethod · 0.80
getAffectedRowsFunction · 0.70

Tested by

no test coverage detected