You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generate a transcription from a video URL using [Supabase](https://supabase.com), [FFmpeg](https://www.ffmpeg.org/) and [Deepgram](https://deepgram.com) and Trigger.dev.
23
20
@@ -40,25 +37,24 @@ The Edge Function triggers a deployed Trigger.dev task which takes a payload fro
40
37
- Ensure TypeScript is installed
41
38
-[Create a Trigger.dev account](https://cloud.trigger.dev)
42
39
-[Create a new Trigger.dev project](/guides/dashboard/creating-a-project)
43
-
-[Create a new Deepgram account](https://deepgram.com/)
40
+
-[Create a new Deepgram account](https://deepgram.com/) and get your API key from the dashboard
44
41
45
42
## Initial setup
46
43
47
44
<Steps>
48
45
<SupabasePrerequisites />
49
46
<CliInitStep />
50
-
<CliDevStep />
51
-
<CliRunTestStep />
52
-
<CliViewRunStep />
53
47
</Steps>
54
48
55
49
## Create and deploy the video processing Trigger.dev task
56
50
57
-
Before setting up your Edge Function and Database Webhook, you'll first need to create your Trigger.dev task. This can be tested independently from the rest of the setup.
51
+
Before setting up your Edge Function and Database Webhook, you'll need to create your Trigger.dev task. This can be tested independently from the rest of the workflow.
58
52
59
-
Create a new task file in your `/trigger` folder (the same place your example task is). Call it `videoProcessAndUpdate.ts`.
53
+
Create a new task file in your `/trigger` folder (the same place your 'Hello World' task is). Call it `videoProcessAndUpdate.ts`.
60
54
61
-
This task with take a video url, extract the audio using FFmpeg and transcribe the audio using Deepgram. We will add the Supabase `update` step further on in the tutorial.
55
+
This task with take a video from a public video url, extract the audio using FFmpeg and transcribe the audio using Deepgram.
56
+
57
+
<Note>We will add the Supabase `update` step further on in the tutorial.</Note>
You'll also need to add `@trigger.dev/build` to your `package.json` file under `devDependencies` if you don't already have it there.
174
169
170
+
### Adding the Deepgram environment variable
171
+
172
+
You will need to add your `DEEPGRAM_SECRET_KEY` as an environment variable in your Trigger.dev project. You can do this in the Trigger.dev dashboard under the 'environment variables' tab.
### Create a new Edge Function using the Supabase CLI
222
223
223
-
Now create a new Edge Function using the Supabase CLI. We will call it `video-processing-handler`. This will trigger our task using the data received from the Database Webhook.
224
+
Now create an Edge Function using the Supabase CLI. Call it `video-processing-handler`. This will trigger your task using the data received from the Database Webhook.
224
225
225
226
```bash
226
227
supabase functions new video-processing-handler
@@ -249,7 +250,6 @@ Deno.serve(async (req) => {
249
250
});
250
251
```
251
252
252
-
<Note>You can only import the `type` from the task.</Note>
253
253
<Note>
254
254
Tasks in the `trigger` folder use Node, so they must stay in there or they will not run,
255
255
especially if you are using a different runtime like Deno. Also do not add "`npm:`" to imports
@@ -274,20 +274,17 @@ There will be a link to the dashboard in your terminal output, or you can find i
274
274
275
275
### Create a new table in your Supabase dashboard
276
276
277
-
Next, in your Supabase project dashboard, click on 'Table Editor' <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" /> in the left-hand menu and create a new table. <Iconicon="circle-2"iconType="solid"size={20}color="A8FF53" />
277
+
Next, in your Supabase dashboard, click on 'Table Editor' <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" /> in the left-hand menu and create a new table. <Iconicon="circle-2"iconType="solid"size={20}color="A8FF53" />
278
278
279
279

280
280
281
-
In this example we will call our table `video_transcriptions`. <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" />
282
-
283
-
Add two new columns, one called `video_url` with the type `text`, and another called `transcription`, also with the type `text`. <Iconicon="circle-2"iconType="solid"size={20}color="A8FF53" />
281
+
Call your table `video_transcriptions`. <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" />
284
282
285
-
<Warning> REPLACE IMAGE BELOW</Warning>
286
-

283
+
Add two new columns, one called `video_url` with the type `text` <Iconicon="circle-2"iconType="solid"size={20}color="A8FF53" />, and another called `transcription`, also with the type `text` <Iconicon="circle-3"iconType="solid"size={20}color="A8FF53" />.
287
284
288
285
### Create a new Database Webhook
289
286
290
-
First, go to your Supabase project dashboard, click 'Project settings' <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" />, then the 'API' tab <Iconicon="circle-2"iconType="solid"size={20}color="A8FF53" />, and copy the `anon``public` API key from the table <Iconicon="circle-3"iconType="solid"size={20}color="A8FF53" />.
287
+
In your Supabase project dashboard, click 'Project settings' <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" />, then the 'API' tab <Iconicon="circle-2"iconType="solid"size={20}color="A8FF53" />, and copy the `anon``public` API key from the table <Iconicon="circle-3"iconType="solid"size={20}color="A8FF53" />.
291
288
292
289

293
290
@@ -324,14 +321,14 @@ and select the Edge Function you have created: `video-processing-handler`.{" "}
324
321
325
322
Your Database Webhook is now ready to use.
326
323
327
-
###Triggering the task
324
+
## Triggering the task
328
325
329
-
### Enabling updates to your supabase tables
326
+
### Adding the logic to update the table row
330
327
331
-
First, you must go back to your task code and add in the Supabase logic:
328
+
First, you must go back to your `videoProcessAndUpdate`task code from earlier and add in the Supabase logic. This will:
332
329
333
-
-Creating a Supabase client (you must update your environment variables in order for this to work)
334
-
-Function to update the table row with the exact match of the `video_url` payload with the new transcription
330
+
-Create a Supabase client (you must update your environment variables in order for this to work)
331
+
-Create a function which updates the table row with the exact match of the `video_url` payload with the new generated transcription.
Your `video-processing-handler` Edge Function is now set up to trigger the `videoProcessAndUpdate` task every time a new row is inserted into your `video_transcriptions` table.
440
443
441
444
To do this, go back to your Supabase project dashboard, click on 'Table Editor' <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" /> in the left-hand menu, click on the `video_transcriptions` table <Iconicon="circle-2"iconType="solid"size={20}color="A8FF53" /> , and then click 'Insert', 'Insert Row' <Iconicon="circle-3"iconType="solid"size={20}color="A8FF53" />.
442
445
443
446

444
447
445
-
Add a new item under `video_url`, with a public video url. <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" />
448
+
Add a new item under `video_url`, with a public video url. <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" />.
446
449
447
-
<Warning> CHANGE IMAGE BELOW </Warning>
450
+
You can use the following public video URL for testing: `https://dpgr.am/spacewalk.wav`.
448
451
449
452

450
453
451
-
<Warning> CHANGE IMAGE BELOW </Warning>
452
-
453
-

454
-
455
-
Then, check your [cloud.trigger.dev](http://cloud.trigger.dev) project 'Runs' list <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" /> and you should see a processing `videoProcessAndUpdate` task <Iconicon="circle-2"iconType="solid"size={20}color="A8FF53" /> which has been triggered when you added a new row with the video url to your `video_transcriptions` table.
454
+
Once the new table row has been inserted, check your [cloud.trigger.dev](http://cloud.trigger.dev) project 'Runs' list <Iconicon="circle-1"iconType="solid"size={20}color="A8FF53" /> and you should see a processing `videoProcessAndUpdate` task <Iconicon="circle-2"iconType="solid"size={20}color="A8FF53" /> which has been triggered when you added a new row with the video url to your `video_transcriptions` table.
456
455
457
456
Once the run has completed successfully, go back to your Supabase `video_transcriptions` table, and you should see that in the row containing the original video URL, the transcription has now been added to the `transcription` column.
458
457
459
-
<Warning> REPLACE BELOW IMAGE </Warning>
460
-

461
-
462
-
**Congratulations! You have completed a full loop from Supabase to Trigger.dev and back again.**
458
+
**Congratulations! You have completed the full workflow from Supabase to Trigger.dev and back again.**
0 commit comments