GithubHelp home page GithubHelp logo

batchtranslate's Introduction

Chinese to Vietnamese Movie Subtitle Translation Scripts

This repository contains a collection of Python scripts designed to assist in translating Chinese movie subtitles to Vietnamese and English. Each script serves a specific purpose in the translation and processing pipeline.

Table of Contents

  1. translate_file_CN2VI.py
  2. poster_maker_root.py
  3. fasttranslate_root_60s_srt_files_to_vtt.py
  4. translate_srt_files.py

translate_file_CN2VI.py

This script is designed to translate Chinese movie subtitles to Vietnamese using a local language model.

Key Features:

  • Uses a local API endpoint (http://localhost:11434) for translation
  • Translates SRT files to VTT format
  • Preserves context by considering previous and next lines
  • Maintains subtitle timing and structure

Usage:

  1. Ensure the local language model API is running
  2. Place SRT files in the script's directory
  3. Run the script: python translate_file_CN2VI.py

The script will process all SRT files in the current directory and its subdirectories, creating corresponding VTT files with Vietnamese translations.

poster_maker_root.py

This script generates poster images for movies by extracting frames from video files.

Key Features:

  • Captures frames from video files at specified intervals
  • Detects faces in the captured frames
  • Selects the best frame based on face detection
  • Saves the selected frame as a poster image

Usage:

  1. Place video files (MP4 format) in the script's directory
  2. Run the script: python poster_maker_root.py

The script will process all MP4 files in the current directory and its subdirectories, creating a '0.jpg' poster image for each video.

fasttranslate_root_60s_srt_files_to_vtt.py

This script uses Google Cloud Translation API to translate SRT files to English and Vietnamese, converting them to VTT format in the process.

Key Features:

  • Translates SRT files to both English and Vietnamese
  • Converts SRT format to VTT format
  • Uses multithreading for faster processing
  • Implements a 60-second timeout for each file

Usage:

  1. Set up Google Cloud credentials (GOOGLE_APPLICATION_CREDENTIALS)
  2. Place SRT files alongside MP4 files in the script's directory
  3. Run the script: python fasttranslate_root_60s_srt_files_to_vtt.py

The script will process all SRT files associated with MP4 files, creating '_en.vtt' and '_vn.vtt' files for each.

translate_srt_files.py

This script is similar to the previous one but focuses on translating SRT files without converting to VTT format.

Key Features:

  • Translates SRT files to both English and Vietnamese
  • Maintains SRT format
  • Uses Google Cloud Translation API

Usage:

  1. Set up Google Cloud credentials (GOOGLE_APPLICATION_CREDENTIALS)
  2. Update the folder_path variable in the script to point to your SRT files
  3. Run the script: python translate_srt_files.py

The script will process all SRT files in the specified folder, creating '_en.srt' and '_vn.srt' files for each.

Setup and Dependencies

To use these scripts, you'll need to install the following Python packages:

pip install opencv-python numpy requests google-cloud-translate tqdm

For the Google Cloud Translation API scripts, you'll need to set up a Google Cloud project and obtain credentials. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to your credentials file.

Note

These scripts are designed to work together in a pipeline for processing movie subtitles. Ensure that you have the necessary permissions and licenses for the content you're translating and processing.

batchtranslate's People

Contributors

hendrywang 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.