Skip to main content

PySubtitle

PySubtitle is a Python library designed to automate the process of generating subtitles for video files. It extracts audio from video files, converts the audio to text using Google's speech recognition services, and generates VTT (Web Video Text Tracks) files for subtitles. This library is particularly useful for creating subtitles for videos in various languages, making content more accessible to a wider audience.

Features

  • Audio Extraction: Extracts audio from video files using ffmpeg.
  • Speech Recognition: Converts audio to text using Google Cloud Speech-to-Text API.
  • Subtitle Generation: Creates VTT files from the transcribed text, with accurate timing and synchronization.
  • Cross-Platform: Works on Windows, macOS, and Linux.

Prerequisites

Before installing and using this library, you need to ensure the following prerequisites are met:

  1. FFmpeg: This library requires ffmpeg to handle video and audio processing. Here's how you can install ffmpeg:

    On Ubuntu:

    sudo apt update
    sudo apt install ffmpeg
    

    On macOS:

    brew install ffmpeg
    

    On Windows:

    Download the binaries from FFmpeg Official Site and follow the installation instructions.

  2. Google Cloud Service Key: This library uses Google Cloud Speech-to-Text API for speech recognition. You need to set up a Google Cloud project and download a service key. Follow these steps:

    • Go to the Google Cloud Console.
    • Create a new project or select an existing one.
    • Enable the Speech-to-Text API for your project.
    • Go to "Credentials" and create a new service account key.
    • Download the JSON key file and set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file.

Installation

To install this library, use pip:

pip install PySubtitle

Usage

Here is a simple example of how to use this library:

from PySubtitle.audio_extraction import extract_audio
from PySubtitle.speech_recognition import audio_to_text
from PySubtitle.vtt_generation import generate_vtt
from PySubtitle.languages import Languages

# Path to your video file
video_path = 'path/to/your/video.mp4'

# Extract audio
audio_path = extract_audio(video_path)

# Convert audio to text
transcripts, durations = audio_to_text(audio_path, Languages.ENGLISH.value)

# Generate VTT file
vtt_file = 'output.vtt'
generate_vtt(transcripts, durations, vtt_file)

Contributing

Contributions are always welcome! Please fork the repository and submit a pull request.

License

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

Metadata

Release files for PySubtitle 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PySubtitle 0.1.2
File Size Uploaded Provenance
PySubtitle-0.1.2.tar.gz 10.6 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for PySubtitle 0.1.2
File Interpreter ABI Platform
PySubtitle-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 MB

Release files / PySubtitle-0.1.2.tar.gz

Download URL PySubtitle-0.1.2.tar.gz
Size 10.6 MB
Tags Source
SHA-256 checksum
How to use checksums
c63210e1aa550425160f2cec7449ec547f1d9b8c7b37dfd272c75978460e4daa
BLAKE2b-256 checksum
How to use checksums
939eb230ca31e46764bde08977c25cb6bf7a987d09d5d48a1cc1f0fc8a3b1432
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.6

Release files / PySubtitle-0.1.2-py3-none-any.whl

Download URL PySubtitle-0.1.2-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ca3396a475e488359eb4f4e440f7604c65b4b5fd986482ef7d3c7ffd58e318b
BLAKE2b-256 checksum
How to use checksums
b88348afc235935aabc33c8b709bc0f02fbeaf4c0b956c1aa35e8bf20fdfe029
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.6

Security for PySubtitle 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page