62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
import asyncio
|
|
from rich.console import Console
|
|
from dubbing.cli import (
|
|
select_language,
|
|
select_model,
|
|
select_project,
|
|
display_cache_status,
|
|
select_cache_strategy,
|
|
confirm_run,
|
|
)
|
|
from dubbing.pipeline import Pipeline
|
|
|
|
console = Console()
|
|
|
|
TRANSLATE_STEP_INDEX = 2
|
|
|
|
|
|
def main():
|
|
console.print("[bold]Fucking Chinese Dramas Dubbing Pipeline[/]\n")
|
|
|
|
# 1. Select project first
|
|
project = select_project()
|
|
if not project:
|
|
return
|
|
console.print(f"[dim]Selected project: {project}[/]\n")
|
|
|
|
# 2. Select language
|
|
language = select_language()
|
|
console.print(f"[dim]Selected language: {language.value.upper()}[/]\n")
|
|
|
|
# 3. Create pipeline with dummy model to check cache
|
|
pipeline = Pipeline(project, "gemini-2.0-flash-lite", language)
|
|
|
|
statuses = pipeline.get_cache_status()
|
|
display_cache_status(statuses)
|
|
console.print()
|
|
|
|
# 4. Select cache strategy
|
|
rebuild_from = select_cache_strategy(statuses)
|
|
|
|
# 5. Only ask for model if translation needs to run
|
|
translate_cached = statuses[TRANSLATE_STEP_INDEX].cached
|
|
needs_translation = (
|
|
rebuild_from >= 0 and rebuild_from <= TRANSLATE_STEP_INDEX
|
|
) or (rebuild_from == -1 and not translate_cached)
|
|
|
|
if needs_translation:
|
|
model = select_model()
|
|
console.print(f"[dim]Selected model: {model}[/]\n")
|
|
pipeline = Pipeline(project, model, language)
|
|
|
|
if not confirm_run():
|
|
console.print("[yellow]Cancelled[/]")
|
|
return
|
|
|
|
console.print()
|
|
asyncio.run(pipeline.run(rebuild_from))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|