Merge pull request #638 from harry0703/dev

bump version to 1.2.4
This commit is contained in:
Harry
2025-05-08 15:45:00 +08:00
committed by GitHub
10 changed files with 408 additions and 506 deletions

View File

@@ -45,7 +45,9 @@ app = _cfg.get("app", {})
whisper = _cfg.get("whisper", {}) whisper = _cfg.get("whisper", {})
proxy = _cfg.get("proxy", {}) proxy = _cfg.get("proxy", {})
azure = _cfg.get("azure", {}) azure = _cfg.get("azure", {})
ui = _cfg.get("ui", {}) ui = _cfg.get("ui", {
"hide_log": False,
})
hostname = socket.gethostname() hostname = socket.gethostname()
@@ -57,7 +59,7 @@ project_description = _cfg.get(
"project_description", "project_description",
"<a href='https://github.com/harry0703/MoneyPrinterTurbo'>https://github.com/harry0703/MoneyPrinterTurbo</a>", "<a href='https://github.com/harry0703/MoneyPrinterTurbo'>https://github.com/harry0703/MoneyPrinterTurbo</a>",
) )
project_version = _cfg.get("project_version", "1.2.3") project_version = _cfg.get("project_version", "1.2.4")
reload_debug = False reload_debug = False
imagemagick_path = app.get("imagemagick_path", "") imagemagick_path = app.get("imagemagick_path", "")

View File

@@ -138,7 +138,6 @@ def combine_videos(
) )
shuffle_side = random.choice(["left", "right", "top", "bottom"]) shuffle_side = random.choice(["left", "right", "top", "bottom"])
logger.info(f"Using transition mode: {video_transition_mode}")
if video_transition_mode.value == VideoTransitionMode.none.value: if video_transition_mode.value == VideoTransitionMode.none.value:
clip = clip clip = clip
elif video_transition_mode.value == VideoTransitionMode.fade_in.value: elif video_transition_mode.value == VideoTransitionMode.fade_in.value:

View File

@@ -1,15 +1,9 @@
[app] [app]
video_source = "pexels" # "pexels" or "pixabay" video_source = "pexels" # "pexels" or "pixabay"
# 是否隐藏配置面板 # 是否隐藏配置面板
# hide_config = false hide_config = false
[user]
# 管理员用户名和密码,用于访问基础设置
username = "admin"
password = "admin"
email = "admin@example.com" # 添加email字段用于身份验证
# Pexels API Key # Pexels API Key
# Register at https://www.pexels.com/api/ to get your API key. # Register at https://www.pexels.com/api/ to get your API key.
# You can use multiple keys to avoid rate limits. # You can use multiple keys to avoid rate limits.
@@ -24,17 +18,18 @@
# 特别注意格式Key 用英文双引号括起来多个Key用逗号隔开 # 特别注意格式Key 用英文双引号括起来多个Key用逗号隔开
pixabay_api_keys = [] pixabay_api_keys = []
# 如果你没有 OPENAI API Key可以使用 g4f 代替,或者使用国内的 Moonshot API
# If you don't have an OPENAI API Key, you can use g4f instead
# 支持的提供商 (Supported providers): # 支持的提供商 (Supported providers):
# openai # openai
# moonshot (月之暗面) # moonshot (月之暗面)
# oneapi
# g4f
# azure # azure
# qwen (通义千问) # qwen (通义千问)
# deepseek
# gemini # gemini
# ollama
# g4f
# oneapi
# cloudflare
# ernie (文心一言)
llm_provider = "openai" llm_provider = "openai"
########## Ollama Settings ########## Ollama Settings
@@ -49,7 +44,7 @@
# No need to set it unless you want to use your own proxy # No need to set it unless you want to use your own proxy
openai_base_url = "" openai_base_url = ""
# Check your available models at https://platform.openai.com/account/limits # Check your available models at https://platform.openai.com/account/limits
openai_model_name = "gpt-4-turbo" openai_model_name = "gpt-4o-mini"
########## Moonshot API Key ########## Moonshot API Key
# Visit https://platform.moonshot.cn/console/api-keys to get your API key. # Visit https://platform.moonshot.cn/console/api-keys to get your API key.
@@ -163,10 +158,6 @@
# 文生视频时的最大并发任务数 # 文生视频时的最大并发任务数
max_concurrent_tasks = 5 max_concurrent_tasks = 5
# webui界面是否显示配置项
# webui hide baisc config panel
hide_config = false
[whisper] [whisper]
# Only effective when subtitle_provider is "whisper" # Only effective when subtitle_provider is "whisper"
@@ -201,3 +192,9 @@
# Get your API key at https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices # Get your API key at https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices
speech_key = "" speech_key = ""
speech_region = "" speech_region = ""
[ui]
# UI related settings
# 是否隐藏日志信息
# Whether to hide logs in the UI
hide_log = false

View File

@@ -1,16 +1,15 @@
moviepy==2.1.1 moviepy==2.1.2
streamlit==1.40.2 streamlit==1.45.0
edge_tts==6.1.19 edge_tts==6.1.19
fastapi==0.115.6 fastapi==0.115.6
uvicorn==0.32.1 uvicorn==0.32.1
openai==1.56.1 openai==1.56.1
faster-whisper==1.1.0 faster-whisper==1.1.0
loguru==0.7.2 loguru==0.7.3
google.generativeai==0.8.3 google.generativeai==0.8.3
dashscope==1.20.14 dashscope==1.20.14
g4f==0.3.8.1 g4f==0.5.2.2
azure-cognitiveservices-speech==1.41.1 azure-cognitiveservices-speech==1.41.1
redis==5.2.0 redis==5.2.0
python-multipart==0.0.19 python-multipart==0.0.19
streamlit-authenticator==0.4.1
pyyaml pyyaml

View File

@@ -42,10 +42,15 @@ st.set_page_config(
) )
hide_streamlit_style = """ streamlit_style = """
<style>#root > div:nth-child(1) > div > div > div > div > section > div {padding-top: 0rem;}</style> <style>
h1 {
padding-top: 0 !important;
}
</style>
""" """
st.markdown(hide_streamlit_style, unsafe_allow_html=True) st.markdown(streamlit_style, unsafe_allow_html=True)
# 定义资源目录 # 定义资源目录
font_dir = os.path.join(root_dir, "resource", "fonts") font_dir = os.path.join(root_dir, "resource", "fonts")
song_dir = os.path.join(root_dir, "resource", "songs") song_dir = os.path.join(root_dir, "resource", "songs")
@@ -93,8 +98,6 @@ support_locales = [
"th-TH", "th-TH",
] ]
# print(f"******** system locale: {system_locale} ********")
if "video_subject" not in st.session_state: if "video_subject" not in st.session_state:
st.session_state["video_subject"] = "" st.session_state["video_subject"] = ""
if "video_script" not in st.session_state: if "video_script" not in st.session_state:
@@ -195,89 +198,9 @@ def tr(key):
loc = locales.get(st.session_state["ui_language"], {}) loc = locales.get(st.session_state["ui_language"], {})
return loc.get("Translation", {}).get(key, key) return loc.get("Translation", {}).get(key, key)
# 加载用户认证配置
# 确保用户配置存在并包含所有必需的字段
if "user" not in config._cfg:
config._cfg["user"] = {
"username": "admin",
"password": "admin",
"email": "admin@example.com",
}
config.save_config()
elif "email" not in config._cfg["user"]:
# 如果用户配置存在但没有email字段添加默认email
config._cfg["user"]["email"] = f"{config._cfg['user']['username']}@example.com"
config.save_config()
# 创建认证对象
authenticator = None
auth_status = False
# 检查是否需要身份验证才能访问配置
if not config.app.get("hide_config", False):
# 创建认证配置
credentials = {
"usernames": {
config._cfg["user"]["username"]: {
"name": config._cfg["user"]["username"],
"password": config._cfg["user"]["password"],
"email": config._cfg["user"]["email"],
}
}
}
cookie_name = "mpt_auth_cookie"
cookie_key = "mpt_auth_key_123"
cookie_expiry_days = 30
authenticator = stauth.Authenticate(
credentials, cookie_name, cookie_key, cookie_expiry_days
)
# 从 session_state 获取认证状态
auth_status = st.session_state.get("authentication_status")
st.write(tr("Get Help"))
llm_provider = config.app.get("llm_provider", "").lower()
if not config.app.get("hide_config", False):
# 创建基础设置折叠框 # 创建基础设置折叠框
if not config.app.get("hide_config", False):
with st.expander(tr("Basic Settings"), expanded=False): with st.expander(tr("Basic Settings"), expanded=False):
# 检查用户是否已登录
if not auth_status:
# 用户未登录,显示登录表单
st.warning(tr("Please login to access settings"))
# 显示登录表单
try:
# 自定义登录表单文本,使用我们的翻译系统
login_form_fields = {
"Form name": tr("Login"),
"Username": tr("Username"),
"Password": tr("Password"),
"Login": tr("Login"),
}
authenticator.login(location="main", fields=login_form_fields)
# 从 session_state 获取认证状态
auth_status = st.session_state.get("authentication_status")
if auth_status is False:
st.error(tr("Incorrect username or password"))
elif auth_status is None:
st.info(tr("Please enter your username and password"))
# 如果用户登录成功,刷新页面以显示配置面板
if auth_status:
st.rerun()
except Exception as e:
st.error(f"{tr('Login Error')}: {e}")
# 只有在用户已登录时才显示配置面板
if auth_status:
config_panels = st.columns(3) config_panels = st.columns(3)
left_config_panel = config_panels[0] left_config_panel = config_panels[0]
middle_config_panel = config_panels[1] middle_config_panel = config_panels[1]
@@ -285,22 +208,22 @@ if not config.app.get("hide_config", False):
# 左侧面板 - 日志设置 # 左侧面板 - 日志设置
with left_config_panel: with left_config_panel:
# 是否隐藏配置面板
hide_config = st.checkbox(
tr("Hide Basic Settings"), value=config.app.get("hide_config", False)
)
config.app["hide_config"] = hide_config
# 是否禁用日志显示 # 是否禁用日志显示
hide_log = st.checkbox( hide_log = st.checkbox(
tr("Hide Log"), value=config.app.get("hide_log", False) tr("Hide Log"), value=config.ui.get("hide_log", False)
) )
config.ui["hide_log"] = hide_log config.ui["hide_log"] = hide_log
# 中间面板 - LLM 设置 # 中间面板 - LLM 设置
with middle_config_panel: with middle_config_panel:
# openai st.write(tr("LLM Settings"))
# moonshot (月之暗面)
# oneapi
# g4f
# azure
# qwen (通义千问)
# gemini
# ollama
llm_providers = [ llm_providers = [
"OpenAI", "OpenAI",
"Moonshot", "Moonshot",
@@ -513,45 +436,21 @@ if not config.app.get("hide_config", False):
if value: if value:
config.app[cfg_key] = value.split(",") config.app[cfg_key] = value.split(",")
st.markdown("##### " + tr("Video API Keys")) st.write(tr("Video Source Settings"))
# Pexels API Key
pexels_api_key = get_keys_from_config("pexels_api_keys") pexels_api_key = get_keys_from_config("pexels_api_keys")
st.markdown(
f"**Pexels API Key** ([{tr('点击获取')}](https://www.pexels.com/api/documentation/))"
)
st.markdown(
f"<span style='color:#FF4B4B'>{tr('推荐使用')}</span>",
unsafe_allow_html=True,
)
pexels_api_key = st.text_input( pexels_api_key = st.text_input(
"Pexels API Key", tr("Pexels API Key"), value=pexels_api_key, type="password"
value=pexels_api_key,
type="password",
key="pexels_api_key_input",
label_visibility="collapsed",
) )
save_keys_to_config("pexels_api_keys", pexels_api_key) save_keys_to_config("pexels_api_keys", pexels_api_key)
# Pixabay API Key
pixabay_api_key = get_keys_from_config("pixabay_api_keys") pixabay_api_key = get_keys_from_config("pixabay_api_keys")
st.markdown(
f"**Pixabay API Key** ([{tr('点击获取')}](https://pixabay.com/api/docs/))"
)
st.markdown(
f"<span style='color:#808080'>{tr('可以不用配置,如果 Pexels 无法使用再选择Pixabay')}</span>",
unsafe_allow_html=True,
)
pixabay_api_key = st.text_input( pixabay_api_key = st.text_input(
"Pixabay API Key", tr("Pixabay API Key"), value=pixabay_api_key, type="password"
value=pixabay_api_key,
type="password",
key="pixabay_api_key_input",
label_visibility="collapsed",
) )
save_keys_to_config("pixabay_api_keys", pixabay_api_key) save_keys_to_config("pixabay_api_keys", pixabay_api_key)
llm_provider = config.app.get("llm_provider", "").lower()
panel = st.columns(3) panel = st.columns(3)
left_panel = panel[0] left_panel = panel[0]
middle_panel = panel[1] middle_panel = panel[1]

View File

@@ -92,8 +92,8 @@
"Synthesizing Voice": "Sprachsynthese läuft, bitte warten...", "Synthesizing Voice": "Sprachsynthese läuft, bitte warten...",
"TTS Provider": "Sprachsynthese-Anbieter auswählen", "TTS Provider": "Sprachsynthese-Anbieter auswählen",
"Hide Log": "Protokoll ausblenden", "Hide Log": "Protokoll ausblenden",
"点击获取": "Klicken zum Abrufen", "Hide Basic Settings": "Basis-Einstellungen ausblenden\n\nWenn diese Option deaktiviert ist, wird die Basis-Einstellungen-Leiste nicht auf der Seite angezeigt.\n\nWenn Sie sie erneut anzeigen möchten, setzen Sie `hide_config = false` in `config.toml`",
"推荐使用": "Empfohlen", "LLM Settings": "**LLM-Einstellungen**",
"可以不用配置,如果 Pexels 无法使用再选择Pixabay": "Kann uneingestellt bleiben. Wenn Pexels nicht funktioniert, wählen Sie Pixabay" "Video Source Settings": "**Videoquellen-Einstellungen**"
} }
} }

View File

@@ -91,6 +91,9 @@
"Voice Example": "This is an example text for testing speech synthesis", "Voice Example": "This is an example text for testing speech synthesis",
"Synthesizing Voice": "Synthesizing voice, please wait...", "Synthesizing Voice": "Synthesizing voice, please wait...",
"TTS Provider": "Select the voice synthesis provider", "TTS Provider": "Select the voice synthesis provider",
"Hide Log": "Hide Log" "Hide Log": "Hide Log",
"Hide Basic Settings": "Hide Basic Settings\n\nHidden, the basic settings panel will not be displayed on the page.\n\nIf you need to display it again, please set `hide_config = false` in `config.toml`",
"LLM Settings": "**LLM Settings**",
"Video Source Settings": "**Video Source Settings**"
} }
} }

View File

@@ -92,8 +92,8 @@
"Synthesizing Voice": "Sintetizando voz, por favor aguarde...", "Synthesizing Voice": "Sintetizando voz, por favor aguarde...",
"TTS Provider": "Selecione o provedor de síntese de voz", "TTS Provider": "Selecione o provedor de síntese de voz",
"Hide Log": "Ocultar Log", "Hide Log": "Ocultar Log",
"点击获取": "Clique para obter", "Hide Basic Settings": "Ocultar Configurações Básicas\n\nOculto, o painel de configurações básicas não será exibido na página.\n\nSe precisar exibi-lo novamente, defina `hide_config = false` em `config.toml`",
"推荐使用": "Recomendado", "LLM Settings": "**Configurações do LLM**",
"可以不用配置,如果 Pexels 无法使用再选择Pixabay": "Pode não ser configurado, se o Pexels não estiver disponível, escolha o Pixabay" "Video Source Settings": "**Configurações da Fonte do Vídeo**"
} }
} }

View File

@@ -92,8 +92,8 @@
"Synthesizing Voice": "Đang tổng hợp giọng nói, vui lòng đợi...", "Synthesizing Voice": "Đang tổng hợp giọng nói, vui lòng đợi...",
"TTS Provider": "Chọn nhà cung cấp tổng hợp giọng nói", "TTS Provider": "Chọn nhà cung cấp tổng hợp giọng nói",
"Hide Log": "Ẩn Nhật Ký", "Hide Log": "Ẩn Nhật Ký",
"点击获取": "Nhấp để lấy", "Hide Basic Settings": "Ẩn Cài Đặt Cơ Bản\n\nẨn, thanh cài đặt cơ bản sẽ không hiển thị trên trang web.\n\nNếu bạn muốn hiển thị lại, vui lòng đặt `hide_config = false` trong `config.toml`",
"推荐使用": "Được khuyến nghị", "LLM Settings": "**Cài Đặt LLM**",
"可以不用配置,如果 Pexels 无法使用再选择Pixabay": "Có thể không cần cấu hình, nếu Pexels không khả dụng, hãy chọn Pixabay" "Video Source Settings": "**Cài Đặt Nguồn Video**"
} }
} }

View File

@@ -2,7 +2,7 @@
"Language": "简体中文", "Language": "简体中文",
"Translation": { "Translation": {
"Login Required": "需要登录", "Login Required": "需要登录",
"Please login to access settings": "请登录后访问配置设置", "Please login to access settings": "请登录后访问配置设置 (:gray[默认用户名: admin, 密码: admin, 您可以在 config.toml 中修改])",
"Username": "用户名", "Username": "用户名",
"Password": "密码", "Password": "密码",
"Login": "登录", "Login": "登录",
@@ -91,6 +91,9 @@
"Voice Example": "这是一段测试语音合成的示例文本", "Voice Example": "这是一段测试语音合成的示例文本",
"Synthesizing Voice": "语音合成中,请稍候...", "Synthesizing Voice": "语音合成中,请稍候...",
"TTS Provider": "语音合成提供商", "TTS Provider": "语音合成提供商",
"Hide Log": "隐藏日志" "Hide Log": "隐藏日志",
"Hide Basic Settings": "隐藏基础设置\n\n隐藏后基础设置面板将不会显示在页面中。\n\n如需要再次显示请在 `config.toml` 中设置 `hide_config = false`",
"LLM Settings": "**大模型设置**",
"Video Source Settings": "**视频源设置**"
} }
} }