SuperAPI AI Directory

audio-video-to-text

Writing & research

View repository

Updated 10-15 17:26

About this skill

Audio/Video to Text

Overview

This skill uses the OpenAI Whisper model to convert audio/video files into text. It supports automatic language detection and multiple output formats.

When to Use

  • Meeting recording to text transcript
  • Generate subtitles for video content (SRT/VTT)
  • Interview/podcast content organization
  • Voice memo to text
  • Preparation for multilingual video translation

Quick Start

1. Install Dependencies

pip install openai-whisper ffmpeg-python

Make sure ffmpeg is installed on the system:

# Ubuntu/Debian
sudo apt-get install ffmpeg

# macOS
brew install ffmpeg

# Windows
# 从 https://ffmpeg.org/download.html 下载

2. Basic Usage

python scripts/transcribe.py <输入文件> [输出文件] [选项]

3. Examples

# 转录 MP4 视频,输出文本
python scripts/transcribe.py meeting.mp4

# 转录音频,输出 SRT 字幕
python scripts/transcribe.py podcast.mp3 podcast.srt --output-format srt

# 指定中文和较小模型(更快)
python scripts/transcribe.py interview.wav --model tiny --language zh

# 输出带时间戳的 JSON
python scripts/transcribe.py video.mp4 result.json --output-format json

Command-Line Options

Option Description Default Value
--model Model size: tiny, base, small, medium, large base
--language Language code: zh, en, ja, etc. Automatic detection
--output-format Output format: txt, srt, vtt, json txt
--device Running device: cpu, cuda cpu
--keep-audio Keep temporary audio files false

Model Selection Guide

Model Size Speed Accuracy Suitable Scenarios
tiny 39M Fastest Average Quick tests, short audio
base 74M Fast Good Daily use
small 244M Medium Better Formal occasions
medium 769M Slow Very good High-accuracy requirements
large 1550M Slowest Best Professional transcription

Output Format Description

TXT (plain text)

这是转录的完整文本内容,适合阅读和编辑。

SRT (subtitle format)

1
00:00:01,000 --> 00:00:04,000
这是第一句字幕。

2
00:00:04,500 --> 00:00:07,000
这是第二句字幕。

VTT (web subtitles)

WEBVTT

00:00:01.000 --> 00:00:04.000
这是第一句字幕。

00:00:04.500 --> 00:00:07.000
这是第二句字幕。

JSON (complete data)

Contains complete information such as segments, timestamps, confidence, etc., suitable for programmatic processing.

Supported File Formats

Audio: MP3, WAV, FLAC, OGG, M4A, AAC

Video: MP4, AVI, MOV, MKV, WEBM, FLV

Performance Optimization Suggestions

  1. For short audio, prioritize tiny/base models - Fast, with sufficient accuracy
  2. Use CPU for long content - Avoid insufficient GPU memory
  3. Specify the language - Can improve accuracy and speed
  4. Batch processing - Scripts can loop to process multiple files

Common Issues

Poor transcription quality

  • Try a larger model (small/medium/large)
  • Specify the correct language code
  • Ensure the audio quality is clear

Slow processing speed

  • Use a smaller model (tiny/base)
  • If there is a GPU, use --device cuda
  • Shorten the audio length or process in segments

Insufficient memory

  • Use a smaller model
  • Split long files and process them separately
  • Close other programs that use memory

Scripts

  • scripts/transcribe.py - Main transcription script

References