利用 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
changed to sync
harry6bfb04f755db
diff --git a/app/controllers/v1/video.py b/app/controllers/v1/video.pyindex 084439c4..0f450eec 100644--- a/app/controllers/v1/video.py+++ b/app/controllers/v1/video.py@@ -16,7 +16,7 @@ router = new_router()@router.post("/videos", response_model=TaskResponse, summary="使用主题来生成短视频")-async def create_video(request: Request, body: TaskVideoRequest):+def create_video(request: Request, body: TaskVideoRequest):task_id = utils.get_uuid()request_id = base.get_task_id(request)try:@@ -26,7 +26,7 @@ async def create_video(request: Request, body: TaskVideoRequest):}body_dict = body.dict()task.update(body_dict)- result = await tm.start(task_id=task_id, params=body)+ result = tm.start(task_id=task_id, params=body)task["result"] = resultlogger.success(f"video created: {utils.to_json(task)}")return utils.get_response(200, task)@@ -35,7 +35,7 @@ async def create_video(request: Request, body: TaskVideoRequest):@router.get("/tasks/{task_id}", response_model=TaskQueryResponse, summary="查询任务状态")-async def get_task(request: Request, task_id: str = Path(..., description="任务ID"),+def get_task(request: Request, task_id: str = Path(..., description="任务ID"),query: TaskQueryRequest = Depends()):request_id = base.get_task_id(request)data = query.dict()diff --git a/app/services/llm.py b/app/services/llm.pyindex 69ec25da..116f3d04 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -37,7 +37,6 @@ def _generate_response(prompt: str) -> str:api_key = config.app.get("oneapi_api_key")model_name = config.app.get("oneapi_model_name")base_url = config.app.get("oneapi_base_url", "")- model_name = config.app.get("g4f_model_name")else:raise ValueError("llm_provider is not set, please set it in the config.toml file.")diff --git a/app/services/task.py b/app/services/task.pyindex 7c8faa44..079556bd 100644--- a/app/services/task.py+++ b/app/services/task.py@@ -21,7 +21,7 @@ def _parse_voice(name: str):return _voice, _lang-async def start(task_id, params: VideoParams):+def start(task_id, params: VideoParams):"""{"video_subject": "",@@ -60,7 +60,7 @@ async def start(task_id, params: VideoParams):subtitle_path = path.join(utils.task_dir(task_id), f"subtitle.srt")logger.info("\n\n## generating audio")- sub_maker =await voice.tts(text=script, voice_name=voice_name, voice_file=audio_file)+ sub_maker = voice.tts(text=script, voice_name=voice_name, voice_file=audio_file)subtitle_provider = config.app.get("subtitle_provider", "").strip().lower()logger.info(f"\n\n## generating subtitle, provider: {subtitle_provider}")diff --git a/app/services/voice.py b/app/services/voice.pyindex 10db25d0..736aab41 100644--- a/app/services/voice.py+++ b/app/services/voice.py@@ -8,7 +8,7 @@ import edge_ttsfrom app.utils import utils-async def tts(text: str, voice_name: str, voice_file: str) -> SubMaker:+def tts(text: str, voice_name: str, voice_file: str) -> SubMaker:logger.info(f"start, voice name: {voice_name}")async def _do() -> SubMaker:@@ -22,7 +22,7 @@ async def tts(text: str, voice_name: str, voice_file: str) -> SubMaker:sub_maker.create_sub((chunk["offset"], chunk["duration"]), chunk["text"])return sub_maker- sub_maker = await _do()+ sub_maker = asyncio.run(_do())logger.info(f"completed, output file: {voice_file}")return sub_maker@@ -100,7 +100,7 @@ if __name__ == "__main__":for voice_name in voice_names:voice_file = f"{temp_dir}/tts-{voice_name}.mp3"subtitle_file = f"{temp_dir}/tts.mp3.srt"- sub_maker = await tts(text=text, voice_name=voice_name, voice_file=voice_file)+ sub_maker = tts(text=text, voice_name=voice_name, voice_file=voice_file)create_subtitle(sub_maker=sub_maker, text=text, subtitle_file=subtitle_file)diff --git a/webui/Main.py b/webui/Main.pyindex 4b50d3c1..1eb913f8 100644--- a/webui/Main.py+++ b/webui/Main.py@@ -151,4 +151,4 @@ if start_button:logger.info("开始生成视频")- asyncio.run(tm.start(task_id=task_id, params=cfg))+ tm.start(task_id=task_id, params=cfg)