|
| 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