-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use pysub2 to gen ass subtitle (#4)
* remove pkg pysrt
- Loading branch information
Showing
11 changed files
with
186 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,5 +161,7 @@ cython_debug/ | |
.idea/ | ||
/.ruff_cache/ | ||
|
||
/assets/*.srt | ||
/assets/*.mkv | ||
/assets/*.mp3 | ||
/assets/*.srt | ||
/assets/*.ass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from tests import util | ||
from yuisub.a2t import WhisperModel | ||
from yuisub.sub import bilingual, load, translate | ||
|
||
|
||
def test_sub() -> None: | ||
sub = load(util.TEST_ENG_SRT) | ||
sub.save(util.projectPATH / "assets" / "test.en.ass") | ||
|
||
|
||
def test_audio() -> None: | ||
model = WhisperModel(name=util.MODEL_NAME, device=util.DEVICE) | ||
|
||
sub = model.transcribe(audio=str(util.TEST_AUDIO)) | ||
sub.save(util.projectPATH / "assets" / "test.audio.ass") | ||
|
||
|
||
@pytest.mark.skipif(os.environ.get("GITHUB_ACTIONS") == "true", reason="Skipping test when running on CI") | ||
def test_bilingual() -> None: | ||
sub = load(util.TEST_ENG_SRT) | ||
|
||
sub_zh = translate( | ||
sub=sub, | ||
model=util.OPENAI_MODEL, | ||
api_key=util.OPENAI_API_KEY, | ||
base_url=util.OPENAI_BASE_URL, | ||
bangumi_url=util.BANGUMI_URL, | ||
) | ||
sub_bilingual = bilingual(sub_origin=sub, sub_zh=sub_zh) | ||
|
||
sub_zh.save(util.projectPATH / "assets" / "test.zh.ass") | ||
sub_bilingual.save(util.projectPATH / "assets" / "test.bilingual.ass") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from yuisub.bangumi import bangumi # noqa: F401 | ||
from yuisub.llm import Translator # noqa: F401 | ||
from yuisub.prompt import ORIGIN, ZH # noqa: F401 | ||
from yuisub.srt import bilingual, from_file # noqa: F401 | ||
from yuisub.sub import bilingual, load, translate # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.