-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsorcery.py
35 lines (25 loc) · 960 Bytes
/
sorcery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import click
from src.commands.translate_command import TranslateCommand
from src.services.openai_service import OpenAIService
@click.command()
@click.option('--target-lang',
default='en',
help='Target language for translation.')
@click.argument('subtitle_files', nargs=-1, required=True)
def translate(subtitle_files, target_lang):
"""
Translates subtitle files to the specified target language.
Args:
subtitle_files (list): A list of subtitle file paths to be translated.
target_lang (str): The target language for translation.
Raises:
FileNotFoundError: If any of the subtitle files cannot be found.
ValueError: If the target language is not supported.
Returns:
None
"""
ai_client = OpenAIService(api_key="my-key")
command = TranslateCommand(subtitle_files, ai_client, target_lang)
command.execute()
if __name__ == '__main__':
translate()