Skip to main content
A speech or audio model needs two things per example: the audio file and the text that goes with it. When the sources are links (talks, interviews, podcasts, lectures), collecting them yourself means a download tool that breaks on servers, an audio converter, a speech-to-text account, and a bucket upload step. This script reads a file of links, imports each one as audio with a transcript, has Importly copy the audio straight into your bucket, and writes a manifest you can load with any training stack. Run it again after adding links: finished clips are skipped, and jobs still running are collected. Use media you have the right to use for training, such as your own content, licensed content, or sources whose terms allow it.

Before you start

Connect your bucket once: Amazon S3, Cloudflare R2, Backblaze B2, DigitalOcean Spaces or Supabase Storage. Save it on the dashboard’s S3 Storage page or with one API call (see Deliver to your bucket). Every import with store: true then lands there. Create your key on the API key page (it’s shown once) and keep it on the machine that runs the script.

The code

build_dataset.py
Run it every few minutes (cron, a scheduled worker, or by hand) until every link is done. Each run collects finished jobs, starts up to 50 new links, and rewrites the manifest.

What you get

The audio is in your bucket under datasets/<DATASET>/audio/<clip id>.mp3, and <DATASET>.jsonl has one line per clip:
Segment times are in seconds, one segment per sentence, so you can cut the audio into sentence-level examples with any audio library, or keep whole clips with their full text. Keep the manifest, not Importly’s mediaUrl: that link expires after 7 days, and the copy in your bucket is yours.

How it works

includeVideo: false downloads only the audio, so you pay for the audio stream, not the video. The file arrives as MP3. transcriptMode: "ai" runs speech-to-text on every clip, so every example gets the same kind of sentence-level segments. If you’d rather use the platform’s captions where they exist (cheaper, but line-by-line timing and sometimes auto-generated), send transcriptMode: "auto" (the default) instead: captions when the clip has them, speech-to-text when it doesn’t. See Transcripts. maxCostDollars caps each link, the download and the transcript together. A link that would go over fails with MAX_COST_EXCEEDED and isn’t charged. storageFilename names the file after a hash of the link. Without it the file is named after the media title, and two clips with the same title would land on the same key. Each link is sent once. The link is the key in SQLite, so re-running the script never imports a clip twice, and failed links stay recorded with their error code.

Errors to handle

Every error has a documentationUrl with the fix. See Error handling.

In production

Thousands of links? Raise MAX_NEW_PER_RUN slowly: a 429 just moves the rest to the next run. Pass a webhookUrl with each import to save results as they finish instead of polling, and keep the status check as a fallback. See Webhooks. Need video too, for a video model or evals? Drop includeVideo: false and set videoQuality (for example "480p"). See POST /import for the quality options.
A 10-minute talk costs about $0.12 here: around $0.02 for the audio download and $0.10 for speech-to-text. Status checks are free. Try it free, no card required. See Pricing & credits.