DEV Community

Aurelix Solutions
Aurelix Solutions

Posted on

TikTok transcripts in Python from the captions TikTok already shows

Most talking TikTok videos already have captions: TikTok generates them automatically with speech recognition, and many creators add or edit their own. A logged-out visitor's video page lists those caption files, in WebVTT or a small JSON format, with start and end times for every line. So for the common case, getting a TikTok transcript is not a speech-to-text job at all. It is a download, and it should cost a fraction of a cent.

This post pulls TikTok transcripts in Python and builds a daily feed of new videos from a few creators.

Disclosure: I'm Aurelix, and I built the TikTok Captions Scraper. It's a paid tool (prices below).

What each row holds

  • transcript_text, word_count, and segments: every caption line as {start, end, text} in seconds. With includeSrt on, an srt field holds the same captions as an SRT file.
  • language (e.g. en, es), language_tag (TikTok's eng-US), is_auto_generated, language_fallback, and available_languages.
  • The video as the page shows it: description, hashtags, author_username, author_name, author_verified, published_date (a UTC date), duration_seconds, and the view, like, comment, share and save counts.
  • status: ok, or why there is no transcript (no_captions, unavailable, invalid_input, not_found, failed). Those rows are not charged for videos you give by link; a profile video without a transcript costs $0.00012.

One video, or a list of them

pip install apify-client
Enter fullscreen mode Exit fullscreen mode
import os

from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("aurelix/tiktok-transcript-scraper").call(
    run_input={
        "videos": [
            "https://www.tiktok.com/@vicky.owens/video/7642780318604299542",
            "https://vm.tiktok.com/ZMhvqjqjq/",
            "7705443263733452054",
        ],
        "languages": ["en"],
    }
)
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    if row["status"] != "ok":
        print("skipped:", row["input"], "-", row["error"])
        continue
    print(row["author_username"], row["published_date"], row["view_count"], "views")
    print(row["transcript_text"][:300], "\n")
Enter fullscreen mode Exit fullscreen mode

Links can be full video URLs, mobile links, short share links or bare numeric IDs. A single video comes back in a few seconds, most of it the run starting, which is quick enough for an AI agent to call the tool through Apify's MCP server in the middle of a conversation.

A creator's latest videos, every morning

Give @usernames in profiles and each one returns its latest videos. With incremental on, a scheduled run returns only videos that earlier runs with the same stateKey did not:

run = client.actor("aurelix/tiktok-transcript-scraper").call(
    run_input={
        "profiles": ["@bbcnews", "@washingtonpost"],
        "maxVideosPerProfile": 10,
        "incremental": True,
        "stateKey": "news-creators-daily",
    }
)
new = [r for r in client.dataset(run["defaultDatasetId"]).iterate_items() if r["status"] == "ok"]
print(len(new), "new videos with captions")
Enter fullscreen mode Exit fullscreen mode

Save the input as a task in Apify Console and schedule it daily; add a Slack incoming-webhook URL in slackWebhookUrl and each run posts the count and the top 10 videos. A video without captions is tried again during its first day, because TikTok adds automatic captions a little after upload.

Profiles come from TikTok's public profile embed, which lists about the 10 newest videos plus pinned ones. That covers a daily feed; for a creator's back catalogue, give the older videos by link.

Timestamps for citations and subtitles

for s in row["segments"][:5]:
    print(f'{s["start"]:6.2f}-{s["end"]:6.2f}  {s["text"]}')
Enter fullscreen mode Exit fullscreen mode

Each segment is one caption line as TikTok shows it, so a summary or an AI answer can point at the exact second. For re-editing, turn on includeSrt and write row["srt"] to a .srt file next to the video.

Why this tool

  • $0.50 per 1,000 videos ($0.20 on paid plans), cheaper than the leading tools.
  • Profiles as well as single videos: the latest ~10 plus pinned.
  • An only-new mode for schedules.
  • What it doesn't cover: speech-to-text for videos without captions. If most of your videos are music-only clips without speech, it will return little.

To see what brands say in their paid TikTok ads, TikTok Ads Library Scraper lists them from TikTok's public EU ad library.

Limits

  • Captions only. No speech-to-text: a video without captions gets a status row instead.
  • About 10 videos per profile. What the public profile embed lists; older videos by link.
  • No translation. Captions come in the languages TikTok serves a logged-out visitor, usually only the video's own.
  • Upload date, not time. TikTok shows a date on the page, so that is what you get.

Cost

You pay per transcript returned, $0.0003 per profile read plus $0.00012 per profile video without a transcript, and a small start fee per run. Videos you give by link without captions, removed or private videos, duplicates and videos an earlier run already returned are free. The current prices are on the Store page; Apify's free plan includes $5 of credit a month, about 10,000 transcripts.

Links

Top comments (0)