The code
transcribe_feed.py
How it works
The audio link comes from the feed. Each RSS item has an<enclosure> with a link to the episode’s audio file. Importly takes direct media links like these, as well as episode pages on supported sites.
"mode": "ai" goes straight to speech-to-text. Podcast audio has no captions, so there’s nothing to check first. For a feed of videos that might have captions, send "mode": "auto" instead: captions cost $0.003 and speech-to-text only runs when there are none.
maxCostDollars caps each episode. Speech-to-text is $0.01 per minute, so the default of $1.50 covers episodes up to 150 minutes. A longer episode fails with MAX_COST_EXCEEDED and isn’t charged. When the length isn’t known up front, the cap is held while the episode is transcribed and the unused part is refunded.
Each episode is sent once. The episode’s guid is the key in SQLite, so a re-run skips everything already started, finished or failed. Unfinished jobs are picked up by the next run, so no run sits waiting on a long episode.
Set language to the show’s language (a two-letter code like es). Without it, speech-to-text transcribes as English.
What gets stored
A finished job fromGET /transcribe/status has the transcript under result. The script stores text, the segments as JSON, and costInDollars:
Errors to handle
Every error has a
documentationUrl with the fix. See Error handling.
In production
Use a webhook instead of polling. Pass awebhookUrl when you start each episode and save the transcript when Importly calls you back. Keep the status check as a fallback. See Webhooks.
Many feeds? Loop over them in the same run. MAX_NEW_PER_RUN keeps a back catalog from starting hundreds of jobs at once, and a 429 just moves the rest to the next run.
Want the audio file too? Send the episode to POST /import with includeTranscript: true and transcriptProvider: "importly" and you get the file in your bucket and the transcript from one job. See Save to your bucket.
Your own speech-to-text key? Add "provider": "deepgram" (or assemblyai, openai) and "apiKey" to pay $0.005 per minute plus your provider’s fees.
A 30-minute episode costs $0.30 with Importly speech-to-text, and status checks are free. Try it free, no card required. See Pricing & credits.