Skip to content

Commit 24b2da6

Browse files
authored
Merge pull request #23 from soniasriv/add-gladia-podcast-shorts
Add gladia-podcast-shorts example
2 parents 5861165 + 028fc80 commit 24b2da6

5 files changed

Lines changed: 636 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Your Shotstack API key: https://dashboard.shotstack.io
2+
SHOTSTACK_API_KEY=
3+
4+
# Your Gladia API key: https://app.gladia.io
5+
GLADIA_API_KEY=
6+
7+
# A public link to the recording you want to cut up
8+
AUDIO_URL=
9+
10+
# Optional. Topics the clips should cover, separated by commas.
11+
KEYWORDS=
12+
13+
# Optional. A public video to play behind the captions.
14+
BACKGROUND_URL=
15+
16+
# Optional. How many clips, and how long each one can be.
17+
CLIP_COUNT=
18+
CLIP_SECONDS=
19+
20+
# Optional. Set to stage for free watermarked test renders.
21+
SHOTSTACK_ENV=
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
output/
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Gladia podcast to vertical shorts
2+
3+
Cut a long recording into short vertical clips. The script sends one audio URL
4+
to Gladia, reads the transcript with speaker labels and word timings, picks the
5+
segments that say the most, and renders each one as a 1080x1920 MP4 with
6+
captions and a speaker tag. You get the clips in `output/` and a manifest that
7+
records where each one starts in the original recording.
8+
9+
The subtitles are cut from the transcript the script already has, so the render
10+
does not transcribe again and consumes no generation credits.
11+
12+
## Requirements
13+
14+
- A [Shotstack account](https://dashboard.shotstack.io/register) and your
15+
**production** API key
16+
- A [Gladia account](https://app.gladia.io) and an API key
17+
- A public link to an audio file, one to three hours long
18+
- Node.js 20 or later
19+
20+
Each run transcribes the recording once and renders one video per clip.
21+
Set `SHOTSTACK_ENV=stage` in `.env` and use your sandbox key for free
22+
watermarked test renders.
23+
24+
## Setup
25+
26+
```bash
27+
git clone https://github.com/shotstack/shotstack-cookbook.git
28+
cd shotstack-cookbook/examples/gladia-podcast-shorts
29+
cp .env.example .env
30+
```
31+
32+
Load the file into your shell. Do this in each new terminal:
33+
34+
```bash
35+
set -a
36+
source .env
37+
set +a
38+
```
39+
40+
Set `AUDIO_URL` to your recording. Set `KEYWORDS` to the topics you want the
41+
clips to cover, separated by commas. Set `BACKGROUND_URL` to a public video if
42+
you want moving footage behind the captions.
43+
44+
## Run
45+
46+
```bash
47+
node podcast-shorts.mjs
48+
```
49+
50+
## What happens
51+
52+
The script asks Gladia to transcribe the recording with diarization, then polls
53+
every five seconds until the status is `done`. It builds every window of
54+
consecutive speech up to `CLIP_SECONDS` long, scores each window by how much is
55+
said in it, and keeps the highest scoring windows that do not overlap. For each
56+
one it uploads a subtitle file to the Shotstack Ingest API, renders a vertical
57+
video that trims the source audio to that window, and downloads the MP4.
58+
59+
Run the script again and it reuses the transcript, so only the renders repeat.
60+
To change how many clips you get, set `CLIP_COUNT` in `.env`.

0 commit comments

Comments
 (0)