利用 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
feat: support custom audio upload in webui
Harrye67a4fe6376c
diff --git a/webui/Main.py b/webui/Main.pyindex dfa30daa..2128aaed 100644--- a/webui/Main.py+++ b/webui/Main.py@@ -509,6 +509,7 @@ right_panel = panel[2]params = VideoParams(video_subject="")uploaded_files = []+uploaded_audio_file = Nonewith left_panel:with st.container(border=True):@@ -859,6 +860,22 @@ with middle_panel:index=2,)+ custom_audio_file_types = ["mp3", "wav", "m4a", "aac", "flac", "ogg"]+ uploaded_audio_file = st.file_uploader(+ tr("Custom Audio File"),+ type=custom_audio_file_types+ + [file_type.upper() for file_type in custom_audio_file_types],+ accept_multiple_files=False,+ key="custom_audio_file_uploader",+ )+ if uploaded_audio_file:+ st.audio(uploaded_audio_file, format="audio/mp3")+ st.info(+ tr(+ "Custom audio will be used directly. TTS synthesis will be skipped for this task."+ )+ )+bgm_options = [(tr("No Background Music"), ""),(tr("Random Background Music"), "random"),@@ -1048,6 +1065,17 @@ if start_button:scroll_to_bottom()st.stop()+ if uploaded_audio_file:+ task_dir = utils.task_dir(task_id)+ # 上传文件名来自浏览器,不能直接拼到磁盘路径里;这里只保留扩展名,+ # 并使用固定文件名保存到当前任务目录,避免路径穿越或特殊字符问题。+ _, audio_ext = os.path.splitext(os.path.basename(uploaded_audio_file.name))+ audio_ext = audio_ext.lower() or ".mp3"+ custom_audio_path = os.path.join(task_dir, f"custom-audio{audio_ext}")+ with open(custom_audio_path, "wb") as f:+ f.write(uploaded_audio_file.getbuffer())+ params.custom_audio_file = custom_audio_path+if uploaded_files:local_videos_dir = utils.storage_dir("local_videos", create=True)# 每次重新上传时都以本次选择的素材为准,避免旧素材不断重复追加。diff --git a/webui/i18n/en.json b/webui/i18n/en.jsonindex 493c7fe0..d750f965 100644--- a/webui/i18n/en.json+++ b/webui/i18n/en.json@@ -42,6 +42,8 @@"Speech Key": "API Key(:red[Required,[Get API Key](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])","Speech Volume": "Speech Volume (1.0 represents 100%)","Speech Rate": "Speech Rate (1.0 means 1x speed)",+ "Custom Audio File": "Custom Audio File",+ "Custom audio will be used directly. TTS synthesis will be skipped for this task.": "Custom audio will be used directly. TTS synthesis will be skipped for this task.","Male": "Male","Female": "Female","Background Music": "Background Music",@@ -119,4 +121,4 @@"Delete Selected Pixabay API Key": "Delete Selected Pixabay API Key","Pixabay API Key deleted successfully": "Pixabay API Key deleted successfully"}-}\ No newline at end of file+}diff --git a/webui/i18n/zh.json b/webui/i18n/zh.jsonindex b8d9bb72..7c2d90a4 100644--- a/webui/i18n/zh.json+++ b/webui/i18n/zh.json@@ -42,6 +42,8 @@"Speech Key": "API Key (:red[必填,密钥1 或 密钥2 均可 [点击获取](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])","Speech Volume": "朗读音量(1.0表示100%)","Speech Rate": "朗读速度(1.0表示1倍速)",+ "Custom Audio File": "自定义音频文件",+ "Custom audio will be used directly. TTS synthesis will be skipped for this task.": "将直接使用自定义音频,本次任务会跳过 TTS 语音合成。","Male": "男性","Female": "女性","Background Music": "背景音乐",@@ -119,4 +121,4 @@"Delete Selected Pixabay API Key": "删除选定的 Pixabay API Key","Pixabay API Key deleted successfully": "Pixabay API Key 删除成功"}-}\ No newline at end of file+}