Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

translate videos using speech recognition

Translate a video's audio using Whisper speech recognition model.

how to use

Add an MP4 file inside the /videos folder and run run_whisper_translate.py to translate from a chosen language to English and produce the output in a folder.

options:

  • --language Russian
  • --task translate
  • --model medium
  • --device cpu default is cuda but it requires additional steps.

more options: whisper


LLM generated project summary

This repository contains a helper script that runs the Whisper CLI to translate videos and organizes the outputs.

Script: run_whisper_translate.py
Key symbols: VIDEOS_DIR, choose_video, unique_path, main

Prerequisites

  • Python 3.8+ installed.
  • Whisper CLI available in PATH (the script checks shutil.which("whisper")).
    • Install official Whisper CLI (example): pip install -U openai-whisper or pip install -U git+https://github.com/openai/whisper.git
  • If you want GPU acceleration, install PyTorch with CUDA and run on a machine with an NVIDIA GPU. The script calls Whisper with --device cuda by default.

How it works

  • Place a single .mp4 file into the videos/ folder (defined by VIDEOS_DIR), or call the script with a path to an mp4 file.
  • The script moves the video into videos/<video_stem>/ and runs Whisper with translation enabled.
  • Outputs (e.g., .srt, .json, .tsv) are saved into the same videos/<video_stem>/ folder.

Usage examples

  • If one .mp4 is already in videos/, run:

    python run_whisper_translate.py
  • To run on a specific file (absolute or relative path):

    python run_whisper_translate.py /path/to/video.mp4

Default options used by the script

  • Language: Russian (--language Russian)
  • Task: translate (--task translate)
  • Model: medium (--model medium)
  • Device: cuda (--device cuda)
  • Output folder: videos/<video_stem>/ (--output_dir <dest_folder>)

Customization

  • To change defaults (language, model, device, etc.) edit the cmd list in main.
  • The script handles duplicate filenames using unique_path.

Troubleshooting

  • "Error: 'whisper' CLI not found in PATH." — install Whisper CLI or add it to PATH.
  • "No .mp4 files found in videos/" — put one .mp4 in videos/ or pass a file path.
  • If multiple .mp4 files are in videos/, specify which to use or remove extras.

Output layout example

  • videos/
    • myvideo/
      • myvideo.mp4
      • myvideo.srt
      • myvideo.json
      • myvideo.tsv

See the script source: run_whisper_translate.py

About

Translate videos locally using speech recognition

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages