Metadata-Version: 2.1
Name: yuisub
Version: 0.0.4
Summary: Auto translation of new anime episodes based on Yui-MHCP001
Home-page: https://github.com/TensoRaws/yuisub
License: GPL-3.0-only
Author: Tohrusky
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: beautifulsoup4
Requires-Dist: openai
Requires-Dist: pydantic
Requires-Dist: pysubs2
Requires-Dist: requests
Requires-Dist: tenacity
Project-URL: Repository, https://github.com/TensoRaws/yuisub
Description-Content-Type: text/markdown

# yuisub

[![codecov](https://codecov.io/gh/TensoRaws/yuisub/branch/main/graph/badge.svg?token=B2TNKYN4O4)](https://codecov.io/gh/TensoRaws/yuisub)
[![CI-test](https://github.com/TensoRaws/yuisub/actions/workflows/CI-test.yml/badge.svg)](https://github.com/TensoRaws/yuisub/actions/workflows/CI-test.yml)
[![Release-pypi](https://github.com/TensoRaws/yuisub/actions/workflows/Release-pypi.yml/badge.svg)](https://github.com/TensoRaws/yuisub/actions/workflows/Release-pypi.yml)
[![PyPI version](https://badge.fury.io/py/yuisub.svg)](https://badge.fury.io/py/yuisub)
![GitHub](https://img.shields.io/github/license/TensoRaws/yuisub)

Auto translation of new anime episodes based on ~~Yui-MHCP001~~ LLM

### Install

Make sure you have Python >= 3.9 installed on your system

```bash
pip install yuisub
```

If you wanna use the `a2t` module, you need to install `Whisper` first

```bash
# pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install openai-whisper
```

### Command Line Usage

`yuisub` can be used from the command line to generate bilingual ASS files. Here's how to use it:

```bash
yuisub -h  # Displays help message
```

### Library

`yuisub` can also be used as a library

### Example

```python3
from yuisub import translate, bilingual, load
from yuisub.a2t import WhisperModel

# sub from audio
model = WhisperModel(name="medium", device="cuda")
sub = model.transcribe(audio="path/to/audio.mp3")

# sub from file
# sub = from_file("path/to/input.srt")

# generate bilingual subtitle
sub_zh = translate(
    sub=sub,
    model="gpt_model_name",
    api_key="your_openai_api_key",
    base_url="api_url",
    bangumi_url="https://bangumi.tv/subject/424883/"
)
sub_bilingual = bilingual(
    sub_origin=sub,
    sub_zh=sub_zh
)

# save the ASS files
sub_zh.save("path/to/output.zh.ass")
sub_bilingual.save("path/to/output.bilingual.ass")
```

### License

This project is licensed under the BSD 3-Clause - see
the [LICENSE file](https://github.com/TohruskyDev/yuisub/blob/main/LICENSE) for details.

