Skip to main content

Generate subtitles (SRT/TXT) from video using OpenAI Whisper.

Project description

Video Subtitler with Whisper

This repository contains a Python application that extracts audio from a video file, transcribes it using OpenAI's Whisper model, and then generates subtitles in SRT format.

Features

  • Audio Extraction: Extracts audio from a video file.
  • Speech Recognition: Transcribes audio to text using OpenAI's Whisper model.
  • Subtitle Generation: Converts transcribed text into SRT format.

Requirements

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/video-subtitler.git
    cd video-subtitler
    
  2. Install the required Python libraries:

    1. if you have CUDA:
      1. Check your cuda version
        nvidia-smi
        
        +-----------------------------------------------------------------------------------------+
        | NVIDIA-SMI 560.94                 Driver Version: 560.94         CUDA Version: 12.6     |
        |-----------------------------------------+------------------------+----------------------+
        | GPU  Name                  Driver-Model | Bus-Id          Disp.A | Volatile Uncorr. ECC |
        | Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
        |                                         |                        |               MIG M. |
        |=========================================+========================+======================|
        |   0  NVIDIA GeForce RTX 3060 Ti   WDDM  |   00000000:07:00.0  On |                  N/A |
        |  0%   45C    P8             26W /  200W |     888MiB /   8192MiB |      2%      Default |
        |                                         |                        |                  N/A |
        +-----------------------------------------+------------------------+----------------------+
        
      2. CUDA Version: 12.6, that means we need to use https://download.pytorch.org/whl/cu126. If your CUDA version is different, change digits after cu to match your version without any dots.
        pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu126
        pip install -r requirements.txt
        
    2. If you don't have CUDA:
      pip install -r requirements.txt
      
  3. Make sure FFmpeg is installed on your system. Visit the FFmpeg download page for installation instructions.

Usage

  1. To use the application, you need to pass the path to the video file as an argument. Optionally, you can specify the paths for the extracted audio and output subtitle file.

    python vsub.py path_to_video.mp4 --audio_file path_to_audio.mp3 --subtitle_file path_to_subtitle.srt
    

    For example:

    python vsub.py video.mp4
    

    This command will extract audio, transcribe it, and generate subtitles in the same directory as the video file.

Files Description

  • vsub.py: The main Python script that orchestrates the extraction, transcription, and subtitle generation.
  • utils/: Contains helper classes for audio extraction, transcription, text merging, and more.
  • requirements.txt: A list of Python libraries required to run the application.

Troubleshooting

If you encounter any issues with the transcription or subtitle generation:

  • Ensure that your FFmpeg installation is up to date.
  • Check that the paths and filenames in the scripts are correct.
  • Verify that the audio and video files are not corrupted and are in a format supported by FFmpeg.

Contributing

Contributions to this project are welcome. Please fork the repository, make your changes, and submit a pull request.

License

This project is open-sourced under the MIT License. See the LICENSE file for more details.

Special thanks!

Thanks @arturtur for script that imports srt file into Adobe After Effects project. Link to the script: Messing with After Effects and Subtitles

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subwhisperer-1.0.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subwhisperer-1.0.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file subwhisperer-1.0.0.tar.gz.

File metadata

  • Download URL: subwhisperer-1.0.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for subwhisperer-1.0.0.tar.gz
Algorithm Hash digest
SHA256 24b00c60371796a76eec13bf8e32ffd408f38780c694af5a2591b60315b36e72
MD5 ec0a345b81caab09afa291159aab8f5c
BLAKE2b-256 2960c1791ec181dd4d63588b60fd0824723bac9cca931894a8efd7d76433eb0c

See more details on using hashes here.

File details

Details for the file subwhisperer-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for subwhisperer-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d9d62c313fd1f68f78514ae43f9f60a6d24371f847de262d4087b79310a0a99
MD5 02f8a9f71d54711df555c4952f4e7c0d
BLAKE2b-256 ccb65be2be52c99d86010bbbc8c88a53797b0f85fb17ab8d8f3a484ef9e74363

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page