Skip to content

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

optimize UI

harry6a5c4e9e7318
diff --git a/webui/Main.py b/webui/Main.py
index 5b8716a9..0689841e 100644
--- a/webui/Main.py
+++ b/webui/Main.py
@@ -41,11 +41,14 @@ hide_streamlit_style = """
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
st.title(f"MoneyPrinterTurbo v{config.project_version}")
+support_locales = ["zh-CN", "zh-HK", "zh-TW", "de-DE", "en-US", "fr-FR", "vi-VN", "th-TH"]
+
font_dir = os.path.join(root_dir, "resource", "fonts")
song_dir = os.path.join(root_dir, "resource", "songs")
i18n_dir = os.path.join(root_dir, "webui", "i18n")
config_file = os.path.join(root_dir, "webui", ".streamlit", "webui.toml")
system_locale = utils.get_system_locale()
+# print(f"******** system locale: {system_locale} ********")
if 'video_subject' not in st.session_state:
st.session_state['video_subject'] = ''
@@ -185,6 +188,7 @@ with st.expander(tr("Basic Settings"), expanded=False):
break
llm_provider = st.selectbox(tr("LLM Provider"), options=llm_providers, index=saved_llm_provider_index)
+ llm_helper = st.container()
llm_provider = llm_provider.lower()
config.app["llm_provider"] = llm_provider
@@ -192,9 +196,97 @@ with st.expander(tr("Basic Settings"), expanded=False):
llm_base_url = config.app.get(f"{llm_provider}_base_url", "")
llm_model_name = config.app.get(f"{llm_provider}_model_name", "")
llm_account_id = config.app.get(f"{llm_provider}_account_id", "")
+
+ tips = ""
+ if llm_provider == 'ollama':
+ if not llm_model_name:
+ llm_model_name = "qwen:7b"
+ if not llm_base_url:
+ llm_base_url = "http://localhost:11434/v1"
+
+ with llm_helper:
+ tips = """
+ ##### Ollama配置说明
+ - **API Key**: 随便填写,比如 123
+ - **Base Url**: 一般为 http://localhost:11434/v1
+ - **Model Name**: 使用 `ollama list` 查看,比如 `qwen:7b`
+ """
+
+ if llm_provider == 'openai':
+ if not llm_model_name:
+ llm_model_name = "gpt-3.5-turbo"
+ with llm_helper:
+ tips = """
+ ##### OpenAI 配置说明
+ > 需要VPN开启全局流量模式
+ - **API Key**: [点击到官网申请](https://platform.openai.com/api-keys)
+ - **Base Url**: 可以留空
+ - **Model Name**: 填写**有权限**的模型,[点击查看模型列表](https://platform.openai.com/settings/organization/limits)
+ """
+
+ if llm_provider == 'moonshot':
+ if not llm_model_name:
+ llm_model_name = "moonshot-v1-8k"
+ with llm_helper:
+ tips = """
+ ##### Moonshot 配置说明
+ - **API Key**: [点击到官网申请](https://platform.moonshot.cn/console/api-keys)
+ - **Base Url**: 固定为 https://api.moonshot.cn/v1
+ - **Model Name**: 比如 moonshot-v1-8k,[点击查看模型列表](https://platform.moonshot.cn/docs/intro#%E6%A8%A1%E5%9E%8B%E5%88%97%E8%A1%A8)
+ """
+
+ if llm_provider == 'qwen':
+ if not llm_model_name:
+ llm_model_name = "qwen-max"
+ with llm_helper:
+ tips = """
+ ##### 通义千问Qwen 配置说明
+ - **API Key**: [点击到官网申请](https://dashscope.console.aliyun.com/apiKey)
+ - **Base Url**: 留空
+ - **Model Name**: 比如 qwen-max,[点击查看模型列表](https://help.aliyun.com/zh/dashscope/developer-reference/model-introduction#3ef6d0bcf91wy)
+ """
+
+ if llm_provider == 'g4f':
+ if not llm_model_name:
+ llm_model_name = "gpt-3.5-turbo"
+ with llm_helper:
+ tips = """
+ ##### gpt4free 配置说明
+ > [GitHub开源项目](https://github.com/xtekky/gpt4free),可以免费使用GPT模型,但是**稳定性较差**
+ - **API Key**: 随便填写,比如 123
+ - **Base Url**: 留空
+ - **Model Name**: 比如 gpt-3.5-turbo,[点击查看模型列表](https://github.com/xtekky/gpt4free/blob/main/g4f/models.py#L308)
+ """
+ if llm_provider == 'azure':
+ with llm_helper:
+ tips = """
+ ##### Azure 配置说明
+ > [点击查看如何部署模型](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/how-to/create-resource)
+ - **API Key**: [点击到Azure后台创建](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI)
+ - **Base Url**: 留空
+ - **Model Name**: 填写你实际的部署名
+ """
+
+ if llm_provider == 'gemini':
+ if not llm_model_name:
+ llm_model_name = "gemini-1.0-pro"
+
+ with llm_helper:
+ tips = """
+ ##### Gemini 配置说明
+ > 需要VPN开启全局流量模式
+ - **API Key**: [点击到官网申请](https://ai.google.dev/)
+ - **Base Url**: 留空
+ - **Model Name**: 比如 gemini-1.0-pro
+ """
+
+ if tips and config.ui['language'] == 'zh':
+ st.info(tips)
+
st_llm_api_key = st.text_input(tr("API Key"), value=llm_api_key, type="password")
st_llm_base_url = st.text_input(tr("Base Url"), value=llm_base_url)
st_llm_model_name = st.text_input(tr("Model Name"), value=llm_model_name)
+
if st_llm_api_key:
config.app[f"{llm_provider}_api_key"] = st_llm_api_key
if st_llm_base_url:
@@ -234,7 +326,7 @@ with left_panel:
video_languages = [
(tr("Auto Detect"), ""),
]
- for code in ["zh-CN", "zh-TW", "de-DE", "en-US", "vi-VN"]:
+ for code in support_locales:
video_languages.append((code, code))
selected_index = st.selectbox(tr("Script Language"),
@@ -300,7 +392,7 @@ with middle_panel:
with st.container(border=True):
st.write(tr("Audio Settings"))
voices = voice.get_all_azure_voices(
- filter_locals=["zh-CN", "zh-HK", "zh-TW", "de-DE", "en-US", "fr-FR", "vi-VN"])
+ filter_locals=support_locales)
friendly_names = {
v: v.
replace("Female", tr("Female")).
@@ -313,7 +405,7 @@ with middle_panel:
saved_voice_name_index = list(friendly_names.keys()).index(saved_voice_name)
else:
for i, v in enumerate(voices):
- if v.lower().startswith(st.session_state['ui_language'].lower()):
+ if v.lower().startswith(st.session_state['ui_language'].lower()) and "V2" not in v:
saved_voice_name_index = i
break
@@ -324,6 +416,7 @@ with middle_panel:
voice_name = list(friendly_names.keys())[list(friendly_names.values()).index(selected_friendly_name)]
params.voice_name = voice_name
config.ui['voice_name'] = voice_name
+
if voice.is_azure_v2_voice(voice_name):
saved_azure_speech_region = config.azure.get(f"speech_region", "")
saved_azure_speech_key = config.azure.get(f"speech_key", "")
@@ -434,12 +527,16 @@ if start_button:
scroll_to_bottom()
result = tm.start(task_id=task_id, params=params)
+ if not result or "videos" not in result:
+ st.error(tr("Video Generation Failed"))
+ logger.error(tr("Video Generation Failed"))
+ scroll_to_bottom()
+ st.stop()
video_files = result.get("videos", [])
st.success(tr("Video Generation Completed"))
try:
if video_files:
- # center the video player
player_cols = st.columns(len(video_files) * 2 + 1)
for i, url in enumerate(video_files):
player_cols[i * 2 + 1].video(url)
diff --git a/webui/i18n/de.json b/webui/i18n/de.json
index 4e3b22f1..433fe173 100644
--- a/webui/i18n/de.json
+++ b/webui/i18n/de.json
@@ -50,6 +50,7 @@
"Generating Video": "Video wird erstellt, bitte warten...",
"Start Generating Video": "Beginne mit der Generierung",
"Video Generation Completed": "Video erfolgreich generiert",
+ "Video Generation Failed": "Video Generierung fehlgeschlagen",
"You can download the generated video from the following links": "Sie können das generierte Video über die folgenden Links herunterladen",
"Basic Settings": "**Grunde Instellungen**",
"Pexels API Key": "Pexels API Key (:red[Required] [Get API Key](https://www.pexels.com/api/))",
diff --git a/webui/i18n/en.json b/webui/i18n/en.json
index 472248f8..6595b6b5 100644
--- a/webui/i18n/en.json
+++ b/webui/i18n/en.json
@@ -50,6 +50,7 @@
"Generating Video": "Generating video, please wait...",
"Start Generating Video": "Start Generating Video",
"Video Generation Completed": "Video Generation Completed",
+ "Video Generation Failed": "Video Generation Failed",
"You can download the generated video from the following links": "You can download the generated video from the following links",
"Pexels API Key": "Pexels API Key (:red[Required] [Get API Key](https://www.pexels.com/api/))",
"Basic Settings": "**Basic Settings** (:blue[Click to expand])",
diff --git a/webui/i18n/vi.json b/webui/i18n/vi.json
index 2dbc6ea8..bb9bc356 100644
--- a/webui/i18n/vi.json
+++ b/webui/i18n/vi.json
@@ -1,66 +1,67 @@
{
"Language": "Tiếng Việt",
"Translation": {
- "Video Script Settings": "**Cài Đặt Kịch Bản Video**",
- "Video Subject": "Chủ Đề Video (Cung cấp một từ khóa, :red[AI sẽ tự động tạo ra] kịch bản video)",
- "Script Language": "Ngôn Ngữ cho Việc Tạo Kịch Bản Video (AI sẽ tự động xuất ra dựa trên ngôn ngữ của chủ đề của bạn)",
- "Generate Video Script and Keywords": "Nhấn để sử dụng AI để tạo [Kịch Bản Video] và [Từ Khóa Video] dựa trên **chủ đề**",
- "Auto Detect": "Tự Động Phát Hiện",
- "Video Script": "Kịch Bản Video (:blue[① Tùy chọn, AI tạo ra ② Dấu câu chính xác giúp việc tạo phụ đề)",
- "Generate Video Keywords": "Nhấn để sử dụng AI để tạo [Từ Khóa Video] dựa trên **kịch bản**",
- "Please Enter the Video Subject": "Vui lòng Nhập Kịch Bản Video Trước",
- "Generating Video Script and Keywords": "AI đang tạo kịch bản video và từ khóa...",
- "Generating Video Keywords": "AI đang tạo từ khóa video...",
- "Video Keywords": "Từ Khóa Video (:blue[① Tùy chọn, AI tạo ra ② Sử dụng dấu phẩy **Tiếng Anh** để phân tách, chỉ sử dụng Tiếng Anh])",
- "Video Settings": "**Cài Đặt Video**",
- "Video Concat Mode": "Chế Độ Nối Video",
- "Random": "Nối Ngẫu Nhiên (Được Khuyến Nghị)",
- "Sequential": "Nối Theo Thứ Tự",
- "Video Ratio": "Tỷ Lệ Khung Hình Video",
- "Portrait": "Dọc 9:16",
- "Landscape": "Ngang 16:9",
- "Clip Duration": "Thời Lượng Tối Đa Của Đoạn Video (giây)",
- "Number of Videos Generated Simultaneously": "Số Video Được Tạo Ra Đồng Thời",
- "Audio Settings": "**Cài Đặt Âm Thanh**",
- "Speech Synthesis": "Giọng Đọc Văn Bản",
- "Speech Region": "Vùng(:red[Bắt Buộc,[Lấy Vùng](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
- "Speech Key": "Khóa API(:red[Bắt Buộc,[Lấy Khóa API](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
- "Speech Volume": "Âm Lượng Giọng Đọc (1.0 đại diện cho 100%)",
- "Male": "Nam",
- "Female": "Nữ",
- "Background Music": "Âm Nhạc Nền",
- "No Background Music": "Không Có Âm Nhạc Nền",
- "Random Background Music": "Âm Nhạc Nền Ngẫu Nhiên",
- "Custom Background Music": "Âm Nhạc Nền Tùy Chỉnh",
- "Custom Background Music File": "Vui lòng nhập đường dẫn tệp cho âm nhạc nền tùy chỉnh:",
- "Background Music Volume": "Âm Lượng Âm Nhạc Nền (0.2 đại diện cho 20%, âm nhạc nền không nên quá to)",
- "Subtitle Settings": "**Cài Đặt Phụ Đề**",
- "Enable Subtitles": "Bật Phụ Đề (Nếu không chọn, các cài đặt dưới đây sẽ không có hiệu lực)",
- "Font": "Phông Chữ Phụ Đề",
- "Position": "Vị Trí Phụ Đề",
- "Top": "Trên",
- "Center": "Giữa",
- "Bottom": "Dưới (Được Khuyến Nghị)",
- "Font Size": "Cỡ Chữ Phụ Đề",
- "Font Color": "Màu Chữ Phụ Đề",
- "Stroke Color": "Màu Viền Phụ Đề",
- "Stroke Width": "Độ Rộng Viền Phụ Đề",
- "Generate Video": "Tạo Video",
- "Video Script and Subject Cannot Both Be Empty": "Chủ Đề Video và Kịch Bản Video không thể cùng trống",
- "Generating Video": "Đang tạo video, vui lòng đợi...",
- "Start Generating Video": "Bắt Đầu Tạo Video",
- "Video Generation Completed": "Hoàn Tất Tạo Video",
- "You can download the generated video from the following links": "Bạn có thể tải video được tạo ra từ các liên kết sau",
- "Pexels API Key": "Khóa API Pexels (:red[Bắt Buộc] [Lấy Khóa API](https://www.pexels.com/api/))",
- "Basic Settings": "**Cài Đặt Cơ Bản** (:blue[Nhấp để mở rộng])",
- "Language": "Ngôn Ngữ",
- "LLM Provider": "Nhà Cung Cấp LLM",
- "API Key": "Khóa API (:red[Bắt Buộc])",
- "Base Url": "Url Cơ Bản",
- "Account ID": "ID Tài Khoản (Lấy từ bảng điều khiển Cloudflare)",
- "Model Name": "Tên Mô Hình",
- "Please Enter the LLM API Key": "Vui lòng Nhập **Khóa API LLM**",
- "Please Enter the Pexels API Key": "Vui lòng Nhập **Khóa API Pexels**",
- "Get Help": "Nếu bạn cần giúp đỡ hoặc có bất kỳ câu hỏi nào, bạn có thể tham gia discord để được giúp đỡ: https://harryai.cc"
+ "Video Script Settings": "**Cài Đặt Kịch Bản Video**",
+ "Video Subject": "Chủ Đề Video (Cung cấp một từ khóa, :red[AI sẽ tự động tạo ra] kịch bản video)",
+ "Script Language": "Ngôn Ngữ cho Việc Tạo Kịch Bản Video (AI sẽ tự động xuất ra dựa trên ngôn ngữ của chủ đề của bạn)",
+ "Generate Video Script and Keywords": "Nhấn để sử dụng AI để tạo [Kịch Bản Video] và [Từ Khóa Video] dựa trên **chủ đề**",
+ "Auto Detect": "Tự Động Phát Hiện",
+ "Video Script": "Kịch Bản Video (:blue[① Tùy chọn, AI tạo ra ② Dấu câu chính xác giúp việc tạo phụ đề)",
+ "Generate Video Keywords": "Nhấn để sử dụng AI để tạo [Từ Khóa Video] dựa trên **kịch bản**",
+ "Please Enter the Video Subject": "Vui lòng Nhập Kịch Bản Video Trước",
+ "Generating Video Script and Keywords": "AI đang tạo kịch bản video và từ khóa...",
+ "Generating Video Keywords": "AI đang tạo từ khóa video...",
+ "Video Keywords": "Từ Khóa Video (:blue[① Tùy chọn, AI tạo ra ② Sử dụng dấu phẩy **Tiếng Anh** để phân tách, chỉ sử dụng Tiếng Anh])",
+ "Video Settings": "**Cài Đặt Video**",
+ "Video Concat Mode": "Chế Độ Nối Video",
+ "Random": "Nối Ngẫu Nhiên (Được Khuyến Nghị)",
+ "Sequential": "Nối Theo Thứ Tự",
+ "Video Ratio": "Tỷ Lệ Khung Hình Video",
+ "Portrait": "Dọc 9:16",
+ "Landscape": "Ngang 16:9",
+ "Clip Duration": "Thời Lượng Tối Đa Của Đoạn Video (giây)",
+ "Number of Videos Generated Simultaneously": "Số Video Được Tạo Ra Đồng Thời",
+ "Audio Settings": "**Cài Đặt Âm Thanh**",
+ "Speech Synthesis": "Giọng Đọc Văn Bản",
+ "Speech Region": "Vùng(:red[Bắt Buộc,[Lấy Vùng](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
+ "Speech Key": "Khóa API(:red[Bắt Buộc,[Lấy Khóa API](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
+ "Speech Volume": "Âm Lượng Giọng Đọc (1.0 đại diện cho 100%)",
+ "Male": "Nam",
+ "Female": "Nữ",
+ "Background Music": "Âm Nhạc Nền",
+ "No Background Music": "Không Có Âm Nhạc Nền",
+ "Random Background Music": "Âm Nhạc Nền Ngẫu Nhiên",
+ "Custom Background Music": "Âm Nhạc Nền Tùy Chỉnh",
+ "Custom Background Music File": "Vui lòng nhập đường dẫn tệp cho âm nhạc nền tùy chỉnh:",
+ "Background Music Volume": "Âm Lượng Âm Nhạc Nền (0.2 đại diện cho 20%, âm nhạc nền không nên quá to)",
+ "Subtitle Settings": "**Cài Đặt Phụ Đề**",
+ "Enable Subtitles": "Bật Phụ Đề (Nếu không chọn, các cài đặt dưới đây sẽ không có hiệu lực)",
+ "Font": "Phông Chữ Phụ Đề",
+ "Position": "Vị Trí Phụ Đề",
+ "Top": "Trên",
+ "Center": "Giữa",
+ "Bottom": "Dưới (Được Khuyến Nghị)",
+ "Font Size": "Cỡ Chữ Phụ Đề",
+ "Font Color": "Màu Chữ Phụ Đề",
+ "Stroke Color": "Màu Viền Phụ Đề",
+ "Stroke Width": "Độ Rộng Viền Phụ Đề",
+ "Generate Video": "Tạo Video",
+ "Video Script and Subject Cannot Both Be Empty": "Chủ Đề Video và Kịch Bản Video không thể cùng trống",
+ "Generating Video": "Đang tạo video, vui lòng đợi...",
+ "Start Generating Video": "Bắt Đầu Tạo Video",
+ "Video Generation Completed": "Hoàn Tất Tạo Video",
+ "Video Generation Failed": "Tạo Video Thất Bại",
+ "You can download the generated video from the following links": "Bạn có thể tải video được tạo ra từ các liên kết sau",
+ "Pexels API Key": "Khóa API Pexels (:red[Bắt Buộc] [Lấy Khóa API](https://www.pexels.com/api/))",
+ "Basic Settings": "**Cài Đặt Cơ Bản** (:blue[Nhấp để mở rộng])",
+ "Language": "Ngôn Ngữ",
+ "LLM Provider": "Nhà Cung Cấp LLM",
+ "API Key": "Khóa API (:red[Bắt Buộc])",
+ "Base Url": "Url Cơ Bản",
+ "Account ID": "ID Tài Khoản (Lấy từ bảng điều khiển Cloudflare)",
+ "Model Name": "Tên Mô Hình",
+ "Please Enter the LLM API Key": "Vui lòng Nhập **Khóa API LLM**",
+ "Please Enter the Pexels API Key": "Vui lòng Nhập **Khóa API Pexels**",
+ "Get Help": "Nếu bạn cần giúp đỡ hoặc có bất kỳ câu hỏi nào, bạn có thể tham gia discord để được giúp đỡ: https://harryai.cc"
}
}
diff --git a/webui/i18n/zh.json b/webui/i18n/zh.json
index 5dbc4bc4..c81d9362 100644
--- a/webui/i18n/zh.json
+++ b/webui/i18n/zh.json
@@ -19,12 +19,12 @@
"Video Ratio": "视频比例",
"Portrait": "竖屏 9:16(抖音视频)",
"Landscape": "横屏 16:9(西瓜视频)",
- "Clip Duration": "视频片段最大时长(秒)",
+ "Clip Duration": "视频片段最大时长(秒)(**不是视频总长度**,是指每个**合成片段**的长度)",
"Number of Videos Generated Simultaneously": "同时生成视频数量",
"Audio Settings": "**音频设置**",
- "Speech Synthesis": "朗读声音(:red[尽量与文案语言保持一致])",
- "Speech Region": "服务区域(:red[必填,[点击获取](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
- "Speech Key": "API Key(:red[必填,[点击获取](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
+ "Speech Synthesis": "朗读声音(:red[**与文案语言保持一致**。注意:V2版效果更好,但是需要API KEY])",
+ "Speech Region": "服务区域 (:red[必填,[点击获取](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
+ "Speech Key": "API Key (:red[必填,密钥1 或 密钥2 均可 [点击获取](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices)])",
"Speech Volume": "朗读音量(1.0表示100%)",
"Male": "男性",
"Female": "女性",
@@ -50,6 +50,7 @@
"Generating Video": "正在生成视频,请稍候...",
"Start Generating Video": "开始生成视频",
"Video Generation Completed": "视频生成完成",
+ "Video Generation Failed": "视频生成失败",
"You can download the generated video from the following links": "你可以从以下链接下载生成的视频",
"Basic Settings": "**基础设置** (:blue[点击展开])",
"Language": "界面语言",