Code Monkey home page Code Monkey logo

localvideosubtitle's Introduction

localVideoSubtitle

Simple python CLI to generate subtitles in batches for local videos with whisper model , based on the insanely-fast-whisper project

How to Install

!pip install -q pipx
!pipx install insanely-fast-whisper

If you got errors AssertionError: Torch not compiled with CUDA enabled error on Windows, try to reinsatll pytorch with

python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

Usage

The script will walk through the user give path for matched media files (audio/video) , for video mode, ffmpeg will be used for extract the audio as an extra step. Example

python batch_transcribe --input-path <root_path_where_media_files_stored> --language russian --mode video
usage: batch_transcribe.py [-h] --input-path INPUT_PATH [--device-id DEVICE_ID] [--output-path OUTPUT_PATH] [--transcript-path TRANSCRIPT_PATH]
                           [--subtitle-path SUBTITLE_PATH] [-f {txt,vtt,srt}] [--model-name MODEL_NAME] [--task {transcribe,translate}] [--language LANGUAGE]
                           [--batch-size BATCH_SIZE] [--flash FLASH] [--timestamp {chunk,word}] [--hf_token HF_TOKEN] [--diarization_model DIARIZATION_MODEL]
                           [--mode {audio,video}]

batch transcribe videos

options:
  -h, --help            show this help message and exit
  --input-path INPUT_PATH
                        Path to the video file(s) to be transcribed.
  --device-id DEVICE_ID
                        Device ID for your GPU. Just pass the device number when using CUDA, or "mps" for Macs with Apple Silicon. (default: "0")
  --output-path OUTPUT_PATH
                        Path to save the audio extract output. (default: current work directory)
  --transcript-path TRANSCRIPT_PATH
                        Path to save the transcription output. (default: current work directory)
  --subtitle-path SUBTITLE_PATH
                        Path to save the transcription output. (default: current work directory)
  -f {txt,vtt,srt}, --subtitle-format {txt,vtt,srt}
                        Format of the output file (default: srt)
  --model-name MODEL_NAME
                        Name of the pretrained model/ checkpoint to perform ASR. (default: openai/whisper-large-v3)
  --task {transcribe,translate}
                        Task to perform: transcribe or translate to another language. (default: transcribe)
  --language LANGUAGE   Language of the input audio. (default: "None" (Whisper auto-detects the language))
  --batch-size BATCH_SIZE
                        Number of parallel batches you want to compute. Reduce if you face OOMs. (default: 24)
  --flash FLASH         Use Flash Attention 2. Read the FAQs to see how to install FA2 correctly. (default: False)
  --timestamp {chunk,word}
                        Whisper supports both chunked as well as word level timestamps. (default: chunk)
  --hf_token HF_TOKEN   Provide a hf.co/settings/token for Pyannote.audio to diarise the audio clips
  --diarization_model DIARIZATION_MODEL
                        Name of the pretrained model/ checkpoint to perform diarization. (default: pyannote/speaker-diarization)
  --mode {audio,video}  Video mode will use ffmpeg for audio extraction first in the pipeline,audio mode pipeline begin with audio files

localvideosubtitle's People

Contributors

gluver avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.