Skip to content

πŸŽ₯ Python tool that automatically generates and translates video subtitles using OpenAI's Whisper model. Supports multiple languages and custom configurations.

License

Notifications You must be signed in to change notification settings

AhmedOsamaMath/video-subtitle-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Video Subtitle Generator

A Python tool that automatically generates subtitles for videos using OpenAI's Whisper model, with optional translation support. The tool transcribes audio from videos and can create subtitle files in both the original language and a translated version.

Features

  • Automatic speech recognition using OpenAI's Whisper model
  • Support for multiple languages
  • Automatic translation capabilities
  • Configurable settings via YAML file
  • Generated SRT subtitle files with proper formatting
  • Easy-to-use command line interface

Installation

  1. Clone this repository:
git clone https://github.com/AhmedOsamaMath/video-subtitle-generator.git
cd video-subtitle-generator
  1. Install the required packages:
pip install -r requirements.txt

Configuration

Create a config.yaml file in the project directory with your desired settings:

# Whisper model to use (tiny, base, small, medium, large)
whisper_model: "base"

# Source language of the video
source_language: "en"

# Whether to generate translated subtitles
translate: true

# Target language for translation
target_language: "ar"

Usage

Basic usage with default configuration:

python script.py path/to/your/video.mp4

Output Files

The script generates two SRT files:

  • videoname_en.srt - Original language subtitles
  • videoname_ar.srt - Translated subtitles (if translation is enabled)

Replace en and ar with your actual source and target language codes.

Project Structure

video-subtitle-generator/
β”œβ”€β”€ script.py         # Main script
β”œβ”€β”€ config.yaml       # Configuration file
β”œβ”€β”€ requirements.txt  # Project dependencies
└── README.md         # Documentation

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

πŸŽ₯ Python tool that automatically generates and translates video subtitles using OpenAI's Whisper model. Supports multiple languages and custom configurations.

Topics

Resources

License

Stars

Watchers

Forks

Languages