Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: auth failed #2

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@
build-backend = "poetry-core.masonry.api"
requires = ["poetry-core"]

[tool.coverage.report]
exclude_also = [
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"except Exception as e"
]

[tool.coverage.run]
omit = ["yuisub"]
omit = [
"./yuisub/__main__.py",
"./yuisub/__init__.py"
]

[tool.mypy]
disable_error_code = "attr-defined"
Expand Down
10 changes: 7 additions & 3 deletions yuisub/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

parser = argparse.ArgumentParser()
parser.description = "Generate bilingual SRT files from audio or SRT input."
# srt
# input
parser.add_argument("-a", "--AUDIO", type=str, help="Path to the audio file", required=False)
parser.add_argument("-s", "--SRT", type=str, help="Path to the input SRT file", required=False)
parser.add_argument("-oz", "--OUTPUT_ZH", type=str, help="Path to save the Chinese SRT file", required=True)
parser.add_argument("-ob", "--OUTPUT_BILINGUAL", type=str, help="Path to save the bilingual SRT file", required=True)
# srt output
parser.add_argument("-oz", "--OUTPUT_ZH", type=str, help="Path to save the Chinese SRT file", required=False)
parser.add_argument("-ob", "--OUTPUT_BILINGUAL", type=str, help="Path to save the bilingual SRT file", required=False)
# openai gpt
parser.add_argument("-om", "--OPENAI_MODEL", type=str, help="Openai model name", required=True)
parser.add_argument("-api", "--OPENAI_API_KEY", type=str, help="Openai API key", required=True)
Expand All @@ -30,6 +31,9 @@ def main() -> None:
if args.AUDIO and args.SRT:
raise ValueError("Please provide only one input file, either audio or SRT.")

if not args.OUTPUT_ZH and not args.OUTPUT_BILINGUAL:
raise ValueError("Please provide output paths for the subtitles.")

if args.AUDIO:
import torch

Expand Down
4 changes: 4 additions & 0 deletions yuisub/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ async def ask(self, question: ORIGIN) -> ZH:
content = json.loads(response.choices[0].message.content)
zh = ZH(**content)

except openai.AuthenticationError as e:
print(f"Authentication Error: {e} retrying...")
raise e

except openai.APIConnectionError as e:
print(f"Connection Error: {e} retrying...")
raise e
Expand Down
Loading