Communitygithub.com

yanghhu/ai-subtitle-generator

Subtitle generation, automatic video captioning, audio-to-subtitle, audio-to-text skill: upload local video or audio (voiceovers, interviews, courses, vlogs, meeting recordings, podcasts) for recognition, generate timed SRT subtitles or export TXT transcripts, JSON (with text, language, and time segments); then add SRT to videos using ffmpeg or CapCut. Also supports simultaneous SRT generation and sentence-level timing when dubbing a script. Before submission, automatically reads the per-second rate, file size, and duration limits from capabilities; rate changes are rejected server-side to avoid unexpected charges. Recognition is done via the Miragea open API, requiring only Python 3.9+ standard library locally—no GPU needed. Compatible with Claude Code, Codex, OpenClaw, Cursor, WorkBuddy.

What is ai-subtitle-generator?

The AI Subtitle Generator skill automates the creation of timed subtitles (SRT), plain text transcripts, and JSON output with time segments from local video or audio files. It supports two main workflows: (1) using the `recognize` command to process pre-recorded media directly into subtitles or transcripts, and (2) using the `voiceover.py script` command to generate both voiceover audio and perfectly aligned subtitles from a written script. This skill is particularly useful for content creators, educators, podcasters, and developers who need efficient captioning without expensive hardware. The backend uses Miragea's cloud API for speech recognition and voice synthesis, meaning no GPU is required locally—only Python 3.9+ standard library. Before any submission, the script automatically fetches current capabilities (rate, size limits) to prevent unexpected charges; rate changes are rejected server-side. It integrates seamlessly with AI agents like Claude Code, Codex, OpenClaw, Cursor, and WorkBuddy, and can output subtitles in SRT for editing in CapCut, Premiere, or via ffmpeg. The skill also includes offline dry-run verification, multi-character voiceover support, and detailed compliance guidance.

Works with✓Claude Code✓Codex CLI✓Cursor
npx skills add https://github.com/yanghhu/miragea-voiceover-skills/tree/HEAD/skills/ai-subtitle-generator

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Subtitle Generation

"Subtitle Generation" is an Agent skill that automatically recognizes local video or audio files into timed SRT subtitles (can also export TXT transcripts or JSON), used for automatic video captioning, audio-to-subtitle, and audio-to-text conversion; it can also generate subtitles synchronously when dubbing a written script, all without requiring a local GPU.

One-Sentence Definition

Subtitle Generation = local video / audio file → recognize → timed .srt (or .txt transcript, .json segments); for script dubbing use voiceover.py script, which also produces voiceover.srt. Recognition is done via the Miragea open API, no local GPU needed.

Two Ways to Generate Subtitles

What You HaveWhat to UseWhat You Get
Already recorded video / audiomiragea_audio.py recognize --file file --wait --output subtitles.srtSRT; --subtitle-format txt for plain text transcript, json for text, language, and time segments
A script not yet dubbedvoiceover.py script script.md -o outDubbed audio voiceover.wav + voiceover.srt aligned to actual audio duration + manifest.json

Audience and Scenarios

Who Uses ItTypical Scenario
Short video creatorsAuto-captioning voiceover / vlog videos, then fine-tune in CapCut
Educators / CoursesGenerate subtitles and transcripts for recorded lectures
Interviews / PodcastersConvert audio to subtitles and text, organize into transcripts
Meeting recordingsExport TXT transcripts as meeting minutes drafts
Commentary channelsFirst transcribe segments into text for script reference
Developers / Agent workflowsJSON segments (start / end / text) for downstream processing

Core Capability Parameters

ItemDescription
Output filesvoiceover.wav (full dubbed audio), voiceover.srt (timed subtitles), manifest.json (per-sentence speaker, text, start/end seconds), lines/ (per-sentence audio, reusable for script revisions)
Voice sourceExisting character actor_id= in your account (query with actors), or a reference audio URL ref= + the actual spoken text ref_text= (voice cloning) that the server can access directly
Generation modeexpressive (client "Default") / standard (client "More Like"); omitted uses server default, real-time value from capabilities
Tone tagstags=tag_name, uses tags[].label from the selected mode in capabilities
Speedspeed= 0.25–4, 1 is normal speed, based on character settings
Multi-roleAt script start, assign a voice for each character; this skill's script calls the official client generate per sentence, then concatenates locally
PausesInline [pause 0.6] / [pause 0.6] (seconds); --gap sets default inter-sentence pause
SubtitlesGenerate SRT based on actual per-sentence audio duration during dubbing (--max-chars, --speaker-labels); for existing audio/video use recognize for SRT / TXT / JSON
Scene presets--preset koubo / jieshuo / daihuo / shuziren / guanggao / youshengshu (voiceover / commentary / livestream selling / digital human / advertisement / audiobook), adjusts only pauses and subtitle character limits
Per-sentence character limit, file size / duration limits, billingBased on real-time capabilities response
Local dependenciesPython 3.9+ standard library, no pip install, no GPU required
Offline dry run--dry-run: no Key needed, no API call, outputs silent placeholder audio and timeline to verify script formatting
Supported AgentsClaude Code, Codex, OpenClaw, Cursor, WorkBuddy, and other agents capable of running Python scripts
Dubbing & Subtitle ServiceMiragea open API (https://miragea.ai/v1)

Quick Start

python3 scripts/voiceover.py check                        # Offline check: Python version, Key set, service URL
export MIRAGEA_API_KEY=your_key                           # Generate at https://miragea.ai/workspace/api, only in env var
python3 scripts/miragea_audio.py capabilities             # Current available generation modes, tone tags, character limit, and billing—based on real-time response
python3 scripts/miragea_audio.py actors --limit 20        # Existing characters and actor_ids in your account (add --offset for pagination when has_more is true)
  • Default API root is https://miragea.ai/v1; set MIRAGEA_BASE_URL (including /v1) only for a private deployment.
  • Do not paste your Key into chat or write it into files. Without a Key, first run the flow with --dry-run.
python3 scripts/miragea_audio.py capabilities                                           # First check subtitles.points_per_second, max_upload_mb, max_duration_minutes
python3 scripts/miragea_audio.py recognize --file video.mp4 --wait --output video.srt       # Auto-caption video
python3 scripts/miragea_audio.py recognize --file interview.mp3 --wait --subtitle-format txt --output interview.txt   # Audio to text
python3 scripts/miragea_audio.py recognize --file course.m4a --wait --subtitle-format json --output course.json # Text + language + time segments
python3 scripts/miragea_audio.py wait taskID --subtitle-format srt --output video.srt     # Resume after timeout, do not resubmit
  • Recognition consumes credits: the script re-reads the current per-second rate as expected_rate before submission; to lock the confirmed rate, add --expected-rate value; if the rate changes, the server rejects the request—confirm before submitting.
  • If the file exceeds the size limit from capabilities, it errors out locally without submission; duration limits are also based on capabilities.
  • --output will not overwrite existing files; use a new filename.
  • Subtitle recognition has no offline dry run; the dubbing-to-subtitle flow can be verified offline with voiceover.py script ... --dry-run.

What You Say → Agent Executes

You SayAgent Executes
"Add subtitles to this video"capabilities to confirm limits → recognize --file video.mp4 --wait --output video.srt → burn in with ffmpeg or import into CapCut
"Convert this recording to text"recognize --file recording.mp3 --wait --subtitle-format txt --output recording.txt
"The video is too large to upload"Extract only the audio track first: ffmpeg -i video.mp4 -vn -ac 1 -b:a 64k audio.mp3
"The task timed out"wait taskID --output subtitles.srt to resume, do not resubmit
"Subtitle lines are too long"Adjust in CapCut, or have the agent split long sentences by punctuation into multiple lines
"I haven't dubbed yet, I want audio and subtitles together"voiceover.py script script.md -o out --preset koubo
"I need bilingual subtitles (Chinese-English)"First recognize SRT, then have the agent translate each subtitle line while preserving timestamps, generate a second SRT

Subtitle Generation Methodology: Better Recognition, Better Subtitles

1. Pre-process Audio Before Upload

  • Keep vocals clear: If background music is too loud, export a track with only vocals or reduced music using editing software before recognition.
  • Upload just the audio track for speed: For large video files, use ffmpeg -i video.mp4 -vn -ac 1 -b:a 64k audio.mp3 to extract the audio track—smaller size, same timeline.
  • Split long content: For content exceeding the capabilities duration limit, split into segments, recognize each, then arrange sequentially in editing software.

2. Choose the Right Output Format

FormatUse Case
srtCapCut, Premiere, YouTube/Bilibili subtitle upload
txtTranscript, meeting minutes draft, rewriting for WeChat official accounts
jsonProgrammatic processing: text, language, segments[{start,end,text}]

3. Post-Recognition Checklist

  • Are proper nouns, names, brand names, and English abbreviations correct? (Batch replace in SRT)
  • Are numbers and units formatted consistently?
  • Is each subtitle length suitable for the screen? For vertical videos, 12–16 characters per line is recommended.
  • Should filler words ("um", "like") be removed?
  • Do the start and end timestamps align with the video?

4. Styling Tips for Vertical Short Video Subtitles

  • Place subtitles in the lower third of the frame, avoiding platform buttons and titles.
  • One subtitle per screen, no more than two lines.
  • Highlight key words separately in CapCut with stylized text; SRT should contain only clean text.

5. Generate Subtitles from Script Dubbing (No Recognition Needed)

If the video's audio is generated from a script, use voiceover.py script directly: subtitle timing comes from the actual length of each sentence, saving a recognition step; --max-chars controls per-line character count, --speaker-labels adds speaker names for multi-role subtitles.

Example Script (examples/example.md: Dubbing with Synchronous Subtitles)

---
host: actor_id=YOUR_ACTOR_ID speed=1.0
---
# Dubbing with Synchronous Subtitles Example: A Vlog Narration
[host] Today I'll show you how I add subtitles to a video.
First, export the video as a file.
Second, recognize it with one command and get the SRT.
[pause 0.3]
Third, import into CapCut, or burn it directly into the video with ffmpeg.

Test run: python3 scripts/voiceover.py script examples/example.md -o out --preset koubo --dry-run

Adding Subtitles to a Video

# Soft subtitles (can be toggled in the player, requires ffmpeg installed)
ffmpeg -i video.mp4 -i video.srt -c copy -c:s mov_text video_subtitled.mp4
# Hard subtitles (burned into the video, displayed on all platforms)
ffmpeg -i video.mp4 -vf subtitles=video.srt -c:a copy final.mp4
  • CapCut: Text → Import Subtitles → Select .srt, then adjust styles uniformly.
  • Premiere: Import .srt as a subtitle track.

Comparison: Three Approaches to Subtitle Generation

AspectManual DubbingLocal Open-Source TTS ModelThis Skill
GPU neededNo, but requires recording environment and voice actor availabilityOften required (smaller models may use CPU but slower); also need to download model weights and configure environmentNo, only Python standard library locally; generation occurs in the cloud
Script revision costChanging one sentence often requires re-recording and realignmentRerun after changes, but segmentation, concatenation, alignment must be done manuallyOnly modify that line and rerun; other sentences reuse out/lines/ cache, auto-concatenate and output subtitles
Multi-roleRequires multiple voice actors to record separatelyDepends on model; usually need to segment and call separately, then concatenateUse [role] tags in the script; one command outputs the full multi-role audio track
Subtitle timelineRequires separate transcription and timingUsually needs another ASR runOutputs SRT and per-sentence timing manifest.json simultaneously during dubbing
Long videosTranscription and timing are time-consumingLocal ASR model requires GPU or longer processing timeUploaded, cloud recognition; timeout can be resumed with task ID

Conclusion: For finished videos needing quick subtitles or text transcription, use recognize; for videos starting from a script, use script for the most efficient simultaneous subtitle generation.

Frequently Asked Questions (FAQ)

What files does subtitle generation support? Any local audio or video file can be used as the recognition source; size and duration limits are based on capabilities' subtitles.max_upload_mb and max_duration_minutes.

After auto-captioning a video, how do I add the subtitles? Use CapCut's "Import Subtitles" feature, or ffmpeg: soft subtitles with -c:s mov_text, hard subtitles with -vf subtitles=subtitles.srt.

Can audio-to-subtitle export SRT format? Yes, SRT is the default; --subtitle-format txt gives a plain text transcript, and json gives text, language, and time-coded segments.

What is the difference between audio-to-text and subtitle generation? They are the same recognition; only the export format differs: SRT includes timestamps for subtitles, TXT is plain text for transcripts.

Is subtitle generation paid? It consumes credits based on media duration and the current per-second rate, as returned in real-time by capabilities; the script submits with the current rate, and any rate change is rejected—no silent deduction at a new rate.

If subtitle generation times out, do I need to re-upload? No. Use the returned task_id to run miragea_audio.py wait taskID --output subtitles.srt to retrieve the result; if the network is interrupted, only retry with the same idempotency key.

Can subtitle generation recognize English or other languages? The recognition result includes a language field; the exact supported languages depend on the server's recognition performance; it's recommended to test with a short segment first.

Can I get bilingual Chinese-English subtitles? First, recognize SRT, then have the agent translate each line while preserving timestamps, generating a second SRT or merging into bilingual format.

Does AI subtitle recognition require a GPU? No. Recognition happens in the cloud; only Python 3.9+ standard library scripts run locally.

Which Agents does this subtitle generation skill support? Claude Code, Codex, OpenClaw, Cursor, WorkBuddy, and other agents that can run Python scripts.

Troubleshooting

IssueAction
missing_api_key / MIRAGEA_API_KEY is not setGenerate a Key and run export MIRAGEA_API_KEY=...; or add --dry-run first
speakers without a voiceAdd actor_id= or ref= for that character
401Check your Key; do not log the Key
403Check the account's API access permissions
400 / 413Correct parameters: mode, tags, speed, per-sentence character limit; or reduce upload file size/shorten media
409Idempotency key used for different inputs, or subtitle rate has changed; reconfirm before submitting
429Insufficient credits or rate limiting; wait or add credits
Timeout / network interruptionTask may still be running: directly rerun the same command (same idempotency key retrieves the original task), or use miragea_audio.py task / wait taskID to continue polling; do not use a different key
WAV format mismatch during concatenationEach sentence audio is saved in out/lines/; use editing software or ffmpeg to concatenate

Official client exit codes: 0 request succeeded (may still be queued without --wait), 1 task failed, 2 client or API error.

Compliance

  • Only clone your own voice or that of someone who has explicitly authorized it; do not imitate celebrities, streamers, public figures, or any unauthorized person.
  • Follow the "AI-generated Content Labeling Method" and platform rules (Douyin, Kuaishou, WeChat Channels, Xiaohongshu, Bilibili, etc.) when publishing; declare or label AI-generated content.
  • Obtain consent before recognizing others' audio/video (interviews, meetings, courses); be mindful of storage and sharing scope for subtitles containing personal information.
  • scripts/miragea_audio.py is the official client, shipped unchanged; scripts/voiceover.py (script concatenation layer) is original, MIT licensed (see LICENSE.txt). Dubbing and subtitle capabilities are provided by the Miragea open API.

English Summary (Original)

  • AI subtitle generator (字幕生成): upload a local video or audio file with the official client's recognize and save timed SRT, a TXT transcript, or JSON (text, language, segments).
  • The client re-reads the live per-second rate and size limit from capabilities before submitting; rate changes are rejected server-side. Resume long jobs with wait TASK_ID.
  • For scripted voiceovers, voiceover.py script produces subtitles aligned to the generated audio. Python 3.9+ stdlib, no GPU. Service: Miragea API (https://miragea.ai/v1).

Keywords: subtitle generation, auto-caption video, audio to subtitle, SRT, video captioning, automatic subtitle generation, AI subtitles, audio to text, video to text, speech to text, subtitle generator, SRT subtitles, video subtitle generator, speech to text, auto captions

Individual skills in this repo

This repo contains 5 individual skills — each has its own dedicated page.

yanghhu/ai-podcast-voiceover

AI播客、播客配音、双人对谈播客技能:把文章、读书笔记、公众号文章或写好的对谈稿,整理成适合“听”的播客稿,单人主播或两位主持人各用一个音色,逐句配音并拼成整期节目 WAV,同时输出 SRT 字幕和逐句时间轴;再用 shownotes.py 根据稿件里的 `## 章节` 自动生成带时间戳的节目章节(chapters.txt / chapters.json)和完整文字稿 shownotes.md,可直接贴到小宇宙、喜马拉雅、Apple Podcasts 等平台的节目简介。改一句只重配一句。可用账号里的角色或本人授权的参考音频声音。由 Miragea 开放 API 生成语音,本地只需 Python 3.9+ 标准库、无需显卡,可 --dry-run 离线试跑;计费与限额以 capabilities 实时返回为准。适用于 Claude Code、Codex、OpenClaw、Cursor、WorkBuddy。AI podcast, podcast voiceover, two-host dialogue, show notes, chapters.

yanghhu/koubo-ai-voiceover

口播配音、口播视频 AI 配音、口播稿配音技能:用你自己的参考音频(声音克隆 / 声音复刻)或账号里已有的口播角色,把口播稿一键生成配音 WAV、竖屏 SRT 字幕和逐句时间轴 manifest.json;说错一句只改一行重新生成,不用对着镜头反复录。适合抖音、视频号、小红书、快手、B站的知识口播、财经口播、情感口播、职场口播博主和 MCN 批量更新;可用语气标签和语速控制口播节奏。配音由 Miragea 开放 API 完成,本地只需 Python 3.9+ 标准库、无需显卡,可 --dry-run 离线试跑。适用于 Claude Code、Codex、OpenClaw、Cursor、WorkBuddy。Talking-head AI voiceover, voice cloning, SRT subtitles.

yanghhu/miragea-video-voiceover

AI配音、视频配音、文字转语音(TTS)、声音克隆与字幕生成技能:把口播稿、电影解说稿、小说推文、广告脚本、带货文案、有声书章节写成带 [角色] 标签的稿件,一条命令生成多角色配音 WAV、带时间轴的 SRT 字幕和逐句时间 manifest.json,直接导入剪映 / CapCut / Premiere / ffmpeg。音色可用账号已有角色,也可用参考音频 + 对应文本做声音克隆;支持语气标签、0.25–4 倍语速、停顿控制;已有音频 / 视频可识别成 SRT / TXT / JSON 字幕。内置口播、解说、带货、数字人、广告片、有声书 6 个节奏预设;改一句只重配一句。配音与字幕由 Miragea 开放 API 生成,本地只需 Python 3.9+ 标准库、无需显卡,可 --dry-run 离线试跑。适用于 Claude Code、Codex、OpenClaw、Cursor、WorkBuddy。AI voiceover, text to speech, voice cloning, multi-speaker dubbing and SRT subtitles.

yanghhu/movie-recap-ai-voiceover

电影解说配音、短剧解说配音、影视解说配音技能:解说旁白(narrator)加多个角色台词,各用不同音色,一条命令生成整段 AI 配音 WAV、SRT 字幕和逐句时间轴 manifest.json,按时间轴在剪映 / CapCut / Premiere 里对画面。音色可用账号已有角色或参考音频声音克隆,打造解说号固定声线;语气标签和语速可调;改一句稿只重配一句。适合电影解说号、电视剧解说、短剧解说、动漫解说、纪录片旁白。配音由 Miragea 开放 API 完成,本地只需 Python 3.9+ 标准库、无需显卡,可 --dry-run 离线试跑。适用于 Claude Code、Codex、OpenClaw、Cursor、WorkBuddy。Movie recap AI voiceover, multi-voice narration, voice cloning, SRT subtitles.

yanghhu/novel-video-voiceover

小说推文配音、有声书配音、多角色配音技能:把小说推文文案、网文章节、故事、广播剧剧本按旁白和角色分配不同音色,一键生成整段配音 WAV、带角色名的 SRT 字幕和逐句时间轴 manifest.json,直接配画面做小说推文视频;段落、场景、章节停顿可控。适合小说推文号、故事号、网文作者有声化、睡前故事和广播剧小样。音色可用账号已有角色或参考音频声音克隆,固定旁白声线;语气标签和语速可调;改一句只重配一句。由 Miragea 开放 API 生成,本地只需 Python 3.9+ 标准库、无需显卡,可 --dry-run 离线试跑。适用于 Claude Code、Codex、OpenClaw、Cursor、WorkBuddy。Novel video voiceover, audiobook narration, multi-voice, SRT subtitles.

Related Skills