利用 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
open the output folder when task completed
harrya7ba6610530e
diff --git a/webui/Main.py b/webui/Main.pyindex ecbec8f9..29be71ff 100644--- a/webui/Main.py+++ b/webui/Main.py@@ -5,26 +5,23 @@ st.set_page_config(page_title="MoneyPrinterTurbo", page_icon="🤖", layout="widimport sysimport osfrom uuid import uuid4-+import platform+import streamlit.components.v1 as componentsfrom loguru import loggerfrom app.models.schema import VideoParams, VideoAspect, VoiceNames, VideoConcatModefrom app.services import task as tm, llm+from app.utils import utilshide_streamlit_style = """<style>#root > div:nth-child(1) > div > div > div > div > section > div {padding-top: 0rem;}</style>"""st.markdown(hide_streamlit_style, unsafe_allow_html=True)st.title("MoneyPrinterTurbo")-st.write(- "⚠️ 先在 **config.toml** 中设置 `pexels_api_keys` 和 `llm_provider` 参数,根据不同的 llm_provider,配置对应的 **API KEY**"-)root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))font_dir = os.path.join(root_dir, "resource", "fonts")song_dir = os.path.join(root_dir, "resource", "songs")-# st.session_state-if 'video_subject' not in st.session_state:st.session_state['video_subject'] = ''if 'video_script' not in st.session_state:@@ -51,6 +48,36 @@ def get_all_songs():return songs+def open_task_folder(task_id):+ try:+ sys = platform.system()+ path = os.path.join(root_dir, "storage", "tasks", task_id)+ if os.path.exists(path):+ if sys == 'Windows':+ os.system(f"start {path}")+ if sys == 'Darwin':+ os.system(f"open {path}")+ except Exception as e:+ logger.error(e)+++def scroll_to_bottom():+ js = f"""+ <script>+ console.log("scroll_to_bottom");+ function scroll(dummy_var_to_force_repeat_execution){{+ var sections = parent.document.querySelectorAll('section.main');+ console.log(sections);+ for(let index = 0; index<sections.length; index++) {{+ sections[index].scrollTop = sections[index].scrollHeight;+ }}+ }}+ scroll(1);+ </script>+ """+ st.components.v1.html(js, height=0, width=0)++def init_log():logger.remove()_lvl = "DEBUG"@@ -87,7 +114,6 @@ left_panel = panel[0]middle_panel = panel[1]right_panel = panel[2]-# define cfg as VideoParams classcfg = VideoParams()with left_panel:@@ -123,7 +149,7 @@ with left_panel:cfg.video_script = st.text_area("视频文案(:blue[①可不填,使用AI生成 ②合理使用标点断句,有助于生成字幕])",value=st.session_state['video_script'],- height=230+ height=180)if st.button("点击使用AI根据**文案**生成【视频关键词】", key="auto_generate_terms"):if not cfg.video_script:@@ -242,12 +268,10 @@ if start_button:task_id = str(uuid4())if not cfg.video_subject and not cfg.video_script:st.error("视频主题 或 视频文案,不能同时为空")+ scroll_to_bottom()st.stop()- st.write(cfg)-log_container = st.empty()-log_records = []@@ -259,6 +283,11 @@ if start_button:logger.add(log_received)+ st.toast("正在生成视频,请稍候...")logger.info("开始生成视频")+ logger.info(utils.to_json(cfg))+ scroll_to_bottom()tm.start(task_id=task_id, params=cfg)+ open_task_folder(task_id)+ logger.info(f"完成")