---
name: Audio to SRT Converter
description: This skill should be used when the user asks to "convert audio to srt", "generate subtitles from audio", "create srt from mp3/wav/m4a/flac", "transcribe audio to subtitles", or needs to generate SRT subtitle files from audio files (MP3, WAV, M4A, FLAC, etc.) with customizable character limits and timeline adjustments.
version: 0.1.0
title: Audio to SRT Converter
canonical_url: https://skilld.dev/gh/dean9703111/ai-agent-skill-for-video-workflow/audio-to-srt
last_updated: 2026-09-24T15:04:04.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [scripts/audio_to_srt.py](https://skilld.dev/api/skills-raw/dean9703111/ai-agent-skill-for-video-workflow/audio-to-srt/scripts/audio_to_srt.py).
>
> If the user asked to install this Skill, run `npx skilld install dean9703111/ai-agent-skill-for-video-workflow/audio-to-srt`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/audio-to-srt`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/dean9703111/ai-agent-skill-for-video-workflow/audio-to-srt) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/audio-to-srt`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/audio-to-srt --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/audio-to-srt --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Audio to SRT Converter

This skill provides a Python-based workflow for converting audio files (MP3, WAV, M4A, FLAC, etc.) into SRT subtitle files with automatic speech recognition, customizable text formatting, and timeline optimization.

## Purpose

Convert audio files (MP3, WAV, M4A, FLAC, etc.) into properly formatted SRT subtitle files with:
- Automatic speech recognition and transcription
- Support for multiple audio formats (MP3, WAV, M4A, FLAC, and more)
- Customizable character limits per subtitle line (default: 22 characters, minimum: 4 characters)
- Automatic timeline gap filling (gaps < 0.3s are merged)
- Environment and dependency validation
- Output naming convention: `origin.srt`

## When to Use This Skill

Use this skill when:
- Converting audio files to subtitle format
- Generating transcriptions with timeline information
- Creating SRT files for video editing or accessibility
- Processing Chinese or multilingual audio content

## Core Workflow

### 1. Environment Validation

Before processing, validate:
- Python 3.7+ is installed
- Required packages are available (see Dependencies section)
- Input MP3 file exists and is readable
- Output directory is writable

### 2. Audio Transcription

Process the audio file using speech recognition:
- Load audio file (supports MP3, WAV, M4A, FLAC, etc.)
- Perform speech-to-text conversion
- Extract timestamps for each segment
- Handle silence detection and word boundaries

### 3. Text Formatting

Format transcribed text according to parameters:
- Split text into lines based on character limit
- Ensure minimum 4 characters per line
- Respect word boundaries when possible
- Handle Chinese character counting correctly

### 4. Timeline Optimization

Adjust subtitle timing:
- Identify gaps between subtitle segments
- Merge segments when gap < 0.3 seconds
- Extend previous subtitle end time to next subtitle start time
- Maintain synchronization with audio

### 5. SRT Generation

Create final SRT file:
- Format according to SRT specification
- Number subtitles sequentially
- Use proper timestamp format (HH:MM:SS,mmm)
- Save as `origin.srt`

## Using the Conversion Script

The main conversion script is located at `scripts/audio_to_srt.py`.

### Basic Usage

```bash
python scripts/audio_to_srt.py <audio_file> [--max-chars MAX_CHARS]
```

### Parameters

- `audio_file` (required): Path to the input audio file (MP3, WAV, M4A, FLAC, etc.)
- `--max-chars` (optional): Maximum characters per subtitle line (default: 22, minimum: 4)

### Examples

See `examples/usage_example.sh` for complete usage examples.

## Dependencies

The script requires the following Python packages:
- `openai-whisper` - For speech recognition
- `pydub` - For audio processing
- `ffmpeg` - System dependency for audio handling

Install with:
```bash
pip install openai-whisper pydub
brew install ffmpeg  # macOS
```

## Output Format

The generated SRT file follows this format:

```
1
00:00:00,000 --> 00:00:03,500
這是第一行字幕

2
00:00:03,500 --> 00:00:07,200
這是第二行字幕
```

## Additional Resources

### Scripts
- **`scripts/audio_to_srt.py`** - Main conversion script with environment validation
- **`scripts/check_environment.py`** - Standalone environment checker

### Examples
- **`examples/usage_example.sh`** - Complete usage examples with different parameters
