agentleFS
bozhouDevbozhouDev/video-skills-toolkit/skills/audio-to-subtitles/SKILL.md

audio-to-subtitles

Skill147 starsChanged 4 months agoMITView on GitHub

Convert local audio/video files or public media URLs into subtitle files by uploading local files to Cloudflare R2 and calling Volcengine AI MediaKit ASR subtitles API. Also supports MiniMax text-to-speech generation from text or text files, with optional subtitle generation from the produced audio. Supports batch processing, SRT/VTT/JSON output, language selection, speaker labels, configurable MiniMax voice ID and model. Use when the user asks to turn audio/video into subtitles, generate ASR subtitles, create SRT/VTT, batch transcription, or generate TTS audio with optional subtitles.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Use this skill to:

    line 8
  2. Distinctive:

    If the input is a local file, upload it to Cloudflare R2 first.

    line 18
  3. Very specific:

    If the media belongs to a talking-head-hyperframes project under <VIDEO_WORKSPACE>, save subtitles under that project's work/captions/.

    line 25
  4. Very specific:

    Use captions.srt and captions.vtt as the main cleaned files, keep raw ASR backups as captions.raw.srt and captions.raw.vtt, and keep the …

    line 26
  5. Very specific:

    If --subtitles is set, upload the audio to R2 and run the same AI MediaKit subtitle workflow.

    line 38
  6. Very specific:

    Do not print API keys or commit real .env.r2 values.

    line 157
  7. Very specific:

    Do not leave finished video subtitles outside the video project.

    line 158

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Audio To Subtitles

Use this skill to:

  • turn local audio/video files or public media URLs into subtitle files through AI MediaKit;
  • turn text into MiniMax TTS audio;
  • optionally generate subtitles from the TTS audio in the same run.

Workflow

For media inputs:

  1. If the input is a local file, upload it to Cloudflare R2 first.
  2. Submit the public audio_url or video_url to AI MediaKit ASR subtitles.
  3. Poll the async task until it is completed or failed.
  4. Save .json, .srt, and .vtt outputs.

For local video-engine projects:

  1. If the media belongs to a talking-head-hyperframes project under <VIDEO_WORKSPACE>, save subtitles under that project's work/captions/.
  2. Use captions.srt and captions.vtt as the main cleaned files, keep raw ASR backups as captions.raw.srt and captions.raw.vtt, and keep the MediaKit payload as asr-result.json.
  3. Also write captions_aligned.json parsed from the cleaned SRT so video-script, talking-head-hyperframes, and hyperframes-scene-animator share the same locked timeline.
  4. The project-local output convention is:
<VIDEO_WORKSPACE>/<project>/work/captions

For text inputs:

  1. Generate audio through MiniMax TTS.
  2. Save the audio file.
  3. If --subtitles is set, upload the audio to R2 and run the same AI MediaKit subtitle workflow.

CLI

# Set this to the directory containing this installed skill (not the current working directory).
SKILL_DIR="<SKILL_ROOT>/audio-to-subtitles"

# Local audio/video: upload to R2, then transcribe
npx -y bun "$SKILL_DIR/scripts/main.ts" audio.mp3 --language zh-CN --out-dir subtitles

# Existing public URL: skip R2 upload
npx -y bun "$SKILL_DIR/scripts/main.ts" "https://example.com/audio.mp3" --out-dir subtitles

# Batch files/URLs
npx -y bun "$SKILL_DIR/scripts/main.ts" a.mp3 b.m4a "https://example.com/video.mp4" --out-dir subtitles

# Batch from manifest
npx -y bun "$SKILL_DIR/scripts/main.ts" --manifest inputs.txt --out-dir subtitles

# Speaker diarization
npx -y bun "$SKILL_DIR/scripts/main.ts" interview.mp3 --speaker --language zh-CN

# Text to audio only
npx -y bun "$SKILL_DIR/scripts/main.ts" --text "你好,欢迎收听。" --voice-id female-shaonv --out-dir audio

# Text file to audio + subtitles
npx -y bun "$SKILL_DIR/scripts/main.ts" --text-file script.md --subtitles --language zh-CN --out-dir audio

Options

OptionDescription
--text <text>Generate MiniMax TTS audio from inline text. Can be repeated.
--text-file <path>Generate MiniMax TTS audio from a text file. Can be repeated.
--subtitlesWith text input, also generate subtitles from the generated audio.
--manifest <path>Batch input manifest. Text files use one input per line; JSON supports an array of strings or objects.
--out-dir <path>Output directory. Default: subtitles.
`--format <allsrtvttjson>`Output format. Comma-separated values are allowed. Default: all.
`--language <cmn-Hans-CNzh-CNeng-US>`Optional recognition language. zh-CN is accepted as an alias for cmn-Hans-CN. Omit to let API choose defaults.
--speakerEnable speaker info and prefix subtitles with speaker labels when returned.
--voice-id <id>MiniMax voice ID. Default: MINIMAX_VOICE_ID, then MINIMAX_TTS_VOICE_ID, then female-shaonv.
--tts-model <model>MiniMax TTS model. Default: MINIMAX_TTS_MODEL, then speech-02-hd.
--tts-speed <n>TTS speed. Default: MINIMAX_TTS_SPEED, then 1.0.
--tts-vol <n>TTS volume. Default: MINIMAX_TTS_VOL, then 1.0.
--tts-pitch <n>TTS pitch. Default: MINIMAX_TTS_PITCH, then 0.
--tts-emotion <emotion>TTS emotion. Default: MINIMAX_TTS_EMOTION, then happy.
`--tts-format <mp3wavflacpcm>`TTS audio format. Default: MINIMAX_TTS_FORMAT, then mp3.
--tts-sample-rate <n>TTS sample rate. Default: MINIMAX_TTS_SAMPLE_RATE, then 32000.
--tts-bitrate <n>TTS bitrate. Default: MINIMAX_TTS_BITRATE, then 128000.
`--media-kind <autoaudiovideo>`Force API request field. Default: auto from extension.
--r2-prefix <prefix>R2 object key prefix for uploaded local audio/video. Default: R2_AUDIO_KEY_PREFIX, then audio/YYYY-MM-DD.
--concurrency <n>Batch concurrency. Default: 1.
--poll-interval <seconds>Poll interval. Default: 5.
--timeout <seconds>Per-task timeout. Default: 7200.
--jsonPrint machine-readable run summary to stdout.

Manifest

Text manifests (.txt) are one media input per line.

JSON manifests can mix media and text jobs:

[
  "local-audio.mp3",
  { "url": "https://example.com/video.mp4", "mediaKind": "video" },
  { "text": "你好,欢迎收听。", "outputName": "intro", "subtitles": true, "voiceId": "female-shaonv" },
  { "textFile": "script.md", "outputName": "script-audio", "subtitles": true }
]

Environment

The script loads environment files in this order. The nearest .env.r2 is loaded last and overrides global R2 defaults for this vault.

  1. ~/.skills/.env
  2. ~/.baoyu-skills/.env
  3. nearest .env.r2 from current directory upward
  4. nearest .skills/.env from current directory upward
  5. nearest .baoyu-skills/.env from current directory upward

Required for MiniMax TTS text input:

VariableDescription
MINIMAX_API_KEYMiniMax API key.
MINIMAX_TTS_API_KEYAlso accepted.
MINIMAX_API_HOSTOptional. Default: https://api.minimax.io.
MINIMAX_VOICE_IDOptional default voice ID.
MINIMAX_TTS_MODELOptional default model.

Required for MediaKit subtitle generation:

VariableDescription
MEDIAKIT_API_KEYAI MediaKit API key.
AI_MEDIAKIT_API_KEYAlso accepted.
VOLCENGINE_MEDIAKIT_API_KEYAlso accepted.

Required for local-file uploads:

VariableDescription
R2_ACCESS_KEY_IDCloudflare R2 access key.
R2_SECRET_ACCESS_KEYCloudflare R2 secret key.
R2_ACCOUNT_IDCloudflare account ID.
R2_BUCKETR2 bucket name.
R2_PUBLIC_BASE_URLPublic base URL. R2_PUBLIC_URL is also accepted.
R2_AUDIO_KEY_PREFIXOptional R2 prefix for uploaded audio/video. Default: audio/YYYY-MM-DD.

Notes

  • AI MediaKit only accepts public HTTP/HTTPS media URLs. Local files must be uploaded first.
  • TTS audio only needs MiniMax API credentials.
  • TTS + subtitles also needs MediaKit and R2 credentials.
  • Supported API languages are currently Simplified Chinese and English.
  • Single media duration should not exceed the AI MediaKit limit of 3 hours.
  • Do not print API keys or commit real .env.r2 values.
  • Do not leave finished video subtitles outside the video project. Copy or write them into the matching <VIDEO_WORKSPACE>/<project>/work/captions/ directory.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.