feat: mvp
This commit is contained in:
100
dubbing/cli.py
Normal file
100
dubbing/cli.py
Normal file
@@ -0,0 +1,100 @@
|
||||
from InquirerPy import inquirer
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
from dubbing.config import settings
|
||||
from dubbing.models import StepStatus, Language
|
||||
|
||||
console = Console()
|
||||
|
||||
|
||||
GEMINI_MODELS = {
|
||||
"gemini-2.0-flash-lite": "Flash Lite (faster, cheaper)",
|
||||
"gemini-2.5-flash": "Flash (better quality)",
|
||||
}
|
||||
|
||||
LANGUAGES = {
|
||||
Language.RU: "Russian (Zh→Ru)",
|
||||
Language.EN: "English (Zh→En)",
|
||||
Language.EN_RU: "Russian via English (Zh→En→Ru)",
|
||||
}
|
||||
|
||||
|
||||
def select_language() -> Language:
|
||||
choices = [{"name": desc, "value": lang} for lang, desc in LANGUAGES.items()]
|
||||
return inquirer.select(
|
||||
message="Select target language:",
|
||||
choices=choices,
|
||||
default=Language.RU,
|
||||
).execute()
|
||||
|
||||
|
||||
def select_model() -> str:
|
||||
choices = [
|
||||
{"name": desc, "value": model_id} for model_id, desc in GEMINI_MODELS.items()
|
||||
]
|
||||
return inquirer.select(
|
||||
message="Select Gemini model:",
|
||||
choices=choices,
|
||||
default="gemini-2.0-flash-lite",
|
||||
).execute()
|
||||
|
||||
|
||||
def get_projects() -> list[str]:
|
||||
settings.projects_dir.mkdir(parents=True, exist_ok=True)
|
||||
return sorted(
|
||||
[
|
||||
d.name
|
||||
for d in settings.projects_dir.iterdir()
|
||||
if d.is_dir() and (d / "source.mp4").exists()
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def select_project() -> str | None:
|
||||
projects = get_projects()
|
||||
if not projects:
|
||||
console.print("[red]No projects found in projects/ directory[/]")
|
||||
console.print("Create a folder with source.mp4 inside projects/")
|
||||
return None
|
||||
|
||||
return inquirer.select(
|
||||
message="Select project:",
|
||||
choices=projects,
|
||||
).execute()
|
||||
|
||||
|
||||
def display_cache_status(statuses: list[StepStatus]) -> None:
|
||||
table = Table(title="Cache Status", show_header=False, box=None)
|
||||
table.add_column("Step", style="cyan")
|
||||
table.add_column("Status")
|
||||
|
||||
for status in statuses:
|
||||
icon = "[green]Cached[/]" if status.cached else "[yellow]Missing[/]"
|
||||
table.add_row(f"├─ {status.name}", icon)
|
||||
|
||||
console.print(table)
|
||||
|
||||
|
||||
def select_cache_strategy(statuses: list[StepStatus]) -> int:
|
||||
choices = [{"name": "Use all cache (Recommended)", "value": -1}]
|
||||
|
||||
for i, status in enumerate(statuses):
|
||||
choices.append(
|
||||
{
|
||||
"name": f"Rebuild from: {status.name}",
|
||||
"value": i,
|
||||
}
|
||||
)
|
||||
|
||||
return inquirer.select(
|
||||
message="Select cache strategy:",
|
||||
choices=choices,
|
||||
default=-1,
|
||||
).execute()
|
||||
|
||||
|
||||
def confirm_run() -> bool:
|
||||
return inquirer.confirm(
|
||||
message="Start pipeline?",
|
||||
default=True,
|
||||
).execute()
|
||||
Reference in New Issue
Block a user