Skip to main content

Tạo phụ đề từ video sử dụng OpenAI Whisper.

Project description

Closed Caption

Closed Caption là một thư viện Python mạnh mẽ, giúp bạn tạo và đồng bộ hóa phụ đề từ video một cách tự động. Thư viện hỗ trợ hai chế độ:

  • Có thời gian: Tự động tạo phụ đề với thời gian đồng bộ từ nội dung âm thanh của video.
  • Không có thời gian: Tạo phụ đề dạng văn bản mà không kèm thời gian.

Tính năng nổi bật

  • Tự động tạo phụ đề từ nội dung âm thanh của video (speech-to-text).

Yêu cầu hệ thống

  • Python >= 3.7
  • FFmpeg (để trích xuất âm thanh từ video)

Cài đặt

  1. Cài đặt thư viện bằng pip:

    pip install closed-caption
    
  2. Cài đặt FFmpeg:

    • Trên Linux (Ubuntu):

      sudo apt update && sudo apt install ffmpeg
      
    • Trên macOS:

      brew install ffmpeg
      
    • Trên Windows:

      • Tải FFmpeg từ ffmpeg.org và thêm vào PATH.

Sử dụng

Tạo phụ đề từ video

1. Tạo phụ đề có thời gian

Tạo file phụ đề .srt với thời gian đồng bộ:

closed_caption video.mp4 output.srt

2. Tạo phụ đề không có thời gian

Tạo file phụ đề .srt không chứa thông tin thời gian:

closed_caption video.mp4 output.srt --no-timing

Sử dụng thư viện trong Python

Tạo phụ đề có thời gian

from closed_caption import create_srt_with_timing

video_path = "video.mp4"
output_srt_path = "output.srt"
create_srt_with_timing(video_path, output_srt_path)

Tạo phụ đề không có thời gian

from closed_caption import create_srt_no_timing

video_path = "video.mp4"
output_srt_path = "output_no_timing.srt"
create_srt_no_timing(video_path, output_srt_path)

Đóng góp

Chúng tôi hoan nghênh mọi đóng góp để cải thiện thư viện. Hãy làm theo các bước sau:

  1. Fork repo này.

  2. Tạo branch mới từ main:

    git checkout -b feature/my-feature
    
  3. Commit thay đổi của bạn:

    git commit -m "Thêm tính năng mới: My Feature"
    
  4. Push branch lên fork của bạn:

    git push origin feature/my-feature
    
  5. Mở Pull Request (PR) và mô tả thay đổi của bạn.

Hướng dẫn kiểm tra

  1. Chạy test:

    python -m unittest discover -s tests
    
  2. Đóng gói thư viện:

    python setup.py sdist bdist_wheel
    
  3. Cài đặt thư viện cục bộ:

    pip install .
    
  4. Chạy thử CLI:

    closed_caption <path-video> <output-path-srt>
    

License

Dự án này được phát hành theo giấy phép MIT. Xem chi tiết tại LICENSE.

Liên hệ

Nếu bạn có bất kỳ câu hỏi hoặc góp ý nào, vui lòng liên hệ tại:


Cảm ơn bạn đã sử dụng Closed Caption!

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

closed-caption-1.0.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

closed_caption-1.0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file closed-caption-1.0.1.tar.gz.

File metadata

  • Download URL: closed-caption-1.0.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.18

File hashes

Hashes for closed-caption-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d25094541533650c5081d4eb6b4c8a4c6c7e622539f67106a4c8661e7355e8a6
MD5 9cedc8fa793f28255c8d98b4e59fe90c
BLAKE2b-256 84bc5234038f11c6c549850fc54126f032ccbc5defd4f75892ce544d48d4972c

See more details on using hashes here.

File details

Details for the file closed_caption-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: closed_caption-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.18

File hashes

Hashes for closed_caption-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 efc30c8993e477d6a4f3ae9a33146557883a744d2083c71b46e353ab6334c1cf
MD5 8cc51e69237abf769b545eb24bafa58f
BLAKE2b-256 ee4ab976c4b6d34ced3f565e220847d3228313989e8dc052cadd8b9f86a2ab7e

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