利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(task): avoid visual term generation for narration-only jobs
Rudy Celekli245fd113500e
diff --git a/app/services/task.py b/app/services/task.pyindex 6334b721..12b18ba2 100644--- a/app/services/task.py+++ b/app/services/task.py@@ -1614,7 +1614,7 @@ def _run_pipeline(# 2. Generate termsvideo_terms = ""- if params.video_source != "local":+ if stop_at in {"terms", "materials", "video"} and params.video_source != "local":video_terms = generate_terms(task_id, params, video_script)if not video_terms:return _mark_task_failed(diff --git a/test/services/test_audio_stage_terms.py b/test/services/test_audio_stage_terms.pynew file mode 100644index 00000000..a7b0dc23--- /dev/null+++ b/test/services/test_audio_stage_terms.py@@ -0,0 +1,30 @@+from unittest.mock import patch+import pytest+from app.models.schema import VideoParams+from app.services import task as tm+from app.services.state import MemoryState+[email protected]("stage", ["audio", "subtitle"])+def test_narration_stages_do_not_depend_on_visual_search_terms(stage):+ params = VideoParams(video_subject="Coffee", video_script="A supplied script", video_source="pexels")+ state = MemoryState()+ with (patch.object(tm.sm, "state", state),+ patch.object(tm.utils, "check_ffmpeg_ready", return_value=True),+ patch.object(tm, "generate_terms", side_effect=RuntimeError("search terms unavailable")) as terms,+ patch.object(tm, "save_script_data") as save,+ patch.object(tm, "generate_audio", return_value=("audio.mp3", 3.0, object())) as audio,+ patch.object(tm, "generate_subtitle", return_value="captions.srt")):+ result = tm.start("task-1", params, stop_at=stage)+ terms.assert_not_called()+ audio.assert_called_once()+ assert state.get_task("task-1")["state"] == tm.const.TASK_STATE_COMPLETE+ assert result == ({"audio_file": "audio.mp3", "audio_duration": 3.0} if stage == "audio" else {"subtitle_path": "captions.srt"})+ assert save.call_args.args[2] == ""++def test_terms_stage_still_generates_visual_search_terms():+ params = VideoParams(video_subject="Coffee", video_script="A supplied script")+ with (patch.object(tm.sm, "state", MemoryState()), patch.object(tm, "save_script_data"),+ patch.object(tm, "generate_terms", return_value=["coffee beans"]) as terms):+ result = tm.start("task-1", params, stop_at="terms")+ terms.assert_called_once()+ assert result["terms"] == ["coffee beans"]