mirror of
https://github.com/linyqh/NarratoAI.git
synced 2025-12-12 11:22:51 +00:00
feat(review_settings): 添加视频剪辑模式选择功能优化默认提示词
- 在视频审查面板中添加剪辑模式选择选项 - 提供三种剪辑模式:仅保留音频、仅保留原声、保留原声和音频- 在 UI 中添加相应的提示信息
This commit is contained in:
parent
0868b8ff4b
commit
9c58102558
@ -5,7 +5,11 @@ import os
|
|||||||
os.environ["HTTP_PROXY"] = config.proxy.get("http")
|
os.environ["HTTP_PROXY"] = config.proxy.get("http")
|
||||||
os.environ["HTTPS_PROXY"] = config.proxy.get("https")
|
os.environ["HTTPS_PROXY"] = config.proxy.get("https")
|
||||||
|
|
||||||
genai.configure(api_key=config.app.get("vision_gemini_api_key"))
|
genai.configure(api_key="AIzaSyBnKPxuPuBpZKGKuR_Sb9CwCIJYJF-N8DM")
|
||||||
model = genai.GenerativeModel("gemini-1.5-flash")
|
# genai.configure(api_key="AIzaSyCm33aPRAZ_P29gTALv0tRerMJwY3zJrq0")
|
||||||
|
model = genai.GenerativeModel("gemini-1.5-pro")
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(50):
|
||||||
response = model.generate_content("直接回复我文本'当前网络可用'")
|
response = model.generate_content("直接回复我文本'当前网络可用'")
|
||||||
print(response.text)
|
print(i, response.text)
|
||||||
|
|||||||
@ -56,6 +56,7 @@ class BaseGenerator:
|
|||||||
当前画面描述:{scene_description}
|
当前画面描述:{scene_description}
|
||||||
|
|
||||||
请确保新生成的文案与上文自然衔接,保持叙事的连贯性和趣味性。
|
请确保新生成的文案与上文自然衔接,保持叙事的连贯性和趣味性。
|
||||||
|
不要出现除了文案以外的其他任何内容;
|
||||||
严格字数要求:{word_count}字,允许误差±5字。"""
|
严格字数要求:{word_count}字,允许误差±5字。"""
|
||||||
|
|
||||||
messages = [
|
messages = [
|
||||||
@ -328,7 +329,9 @@ class ScriptProcessor:
|
|||||||
self.generator = OpenAIGenerator(model_name, self.api_key, self.prompt, self.base_url)
|
self.generator = OpenAIGenerator(model_name, self.api_key, self.prompt, self.base_url)
|
||||||
|
|
||||||
def _get_default_prompt(self) -> str:
|
def _get_default_prompt(self) -> str:
|
||||||
return f"""你是一位极具幽默感的短视频脚本创作大师,擅长用"温和的违反"制造笑点,让{self.video_theme}视频既有趣又富有传播力。你的任务是将视频画面描述转化为能在社交平台疯狂传播的爆款口播文案。
|
return f"""
|
||||||
|
你是一位极具幽默感的短视频脚本创作大师,擅长用"温和的违反"制造笑点,让主题为 《{self.video_theme}》 的视频既有趣又富有传播力。
|
||||||
|
你的任务是将视频画面描述转化为能在社交平台疯狂传播的爆款口播文案。
|
||||||
|
|
||||||
目标受众:热爱生活、追求独特体验的18-35岁年轻人
|
目标受众:热爱生活、追求独特体验的18-35岁年轻人
|
||||||
文案风格:基于HKRR理论 + 段子手精神
|
文案风格:基于HKRR理论 + 段子手精神
|
||||||
@ -342,17 +345,16 @@ class ScriptProcessor:
|
|||||||
【爆款内容四要素】
|
【爆款内容四要素】
|
||||||
|
|
||||||
【快乐元素 Happy】
|
【快乐元素 Happy】
|
||||||
1. 用调侃的语气描述建造过程中的"笨手笨脚"
|
1. 用调侃的语气描述画面
|
||||||
2. 巧妙植入网络流行梗,增加内容的传播性
|
2. 巧妙植入网络流行梗,增加内容的传播性
|
||||||
3. 适时自嘲,展现真实且有趣的一面
|
3. 适时自嘲,展现真实且有趣的一面
|
||||||
|
|
||||||
【知识价值 Knowledge】
|
【知识价值 Knowledge】
|
||||||
1. 用段子手的方式解释专业知识(比如:"这根木头不是一般的木头,它比我前任还难搞...")
|
1. 用段子手的方式解释专业知识
|
||||||
2. 把复杂的建造技巧转化为生动有趣的比喻
|
2. 在幽默中传递实用的生活常识
|
||||||
3. 在幽默中传递实用的野外生存技能
|
|
||||||
|
|
||||||
【情感共鸣 Resonance】
|
【情感共鸣 Resonance】
|
||||||
1. 描述"真实但夸张"的建造困境
|
1. 描述"真实但夸张"的环境描述
|
||||||
2. 把对自然的感悟融入俏皮话中
|
2. 把对自然的感悟融入俏皮话中
|
||||||
3. 用接地气的表达方式拉近与观众距离
|
3. 用接地气的表达方式拉近与观众距离
|
||||||
|
|
||||||
@ -366,10 +368,10 @@ class ScriptProcessor:
|
|||||||
2. 使用恰当的连接词和过渡语,确保叙事流畅
|
2. 使用恰当的连接词和过渡语,确保叙事流畅
|
||||||
3. 保持人物视角和语气的一致性
|
3. 保持人物视角和语气的一致性
|
||||||
4. 避免重复上一段已经提到的信息
|
4. 避免重复上一段已经提到的信息
|
||||||
5. 确保情节和建造过程的逻辑连续性
|
5. 确保情节的逻辑连续性
|
||||||
|
|
||||||
我会按顺序提供多段视频画面描述。请创作既搞笑又能火爆全网的口播文案。
|
我会按顺序提供多段视频画面描述。请创作既搞笑又能火爆全网的口播文案。
|
||||||
记住:要敢于用"温和的违反"制造笑点,但要把握好尺度,让观众在轻松愉快中感受野外建造的乐趣。"""
|
记住:要敢于用"温和的违反"制造笑点,但要把握好尺度,让观众在轻松愉快中感受到乐趣。"""
|
||||||
|
|
||||||
def calculate_duration_and_word_count(self, time_range: str) -> int:
|
def calculate_duration_and_word_count(self, time_range: str) -> int:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -394,10 +394,6 @@ def cut_video(params, progress_callback=None):
|
|||||||
video_script_list = st.session_state['video_clip_json']
|
video_script_list = st.session_state['video_clip_json']
|
||||||
time_list = [i['timestamp'] for i in video_script_list]
|
time_list = [i['timestamp'] for i in video_script_list]
|
||||||
|
|
||||||
total_clips = len(time_list)
|
|
||||||
|
|
||||||
print("time_list", time_list)
|
|
||||||
|
|
||||||
def clip_progress(current, total):
|
def clip_progress(current, total):
|
||||||
progress = int((current / total) * 100)
|
progress = int((current / total) * 100)
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
@ -414,17 +410,11 @@ def cut_video(params, progress_callback=None):
|
|||||||
raise ValueError("裁剪视频失败")
|
raise ValueError("裁剪视频失败")
|
||||||
|
|
||||||
st.session_state['subclip_videos'] = subclip_videos
|
st.session_state['subclip_videos'] = subclip_videos
|
||||||
|
|
||||||
print("list:", subclip_videos)
|
|
||||||
|
|
||||||
for i, video_script in enumerate(video_script_list):
|
for i, video_script in enumerate(video_script_list):
|
||||||
print(i)
|
|
||||||
print(video_script)
|
|
||||||
try:
|
try:
|
||||||
video_script['path'] = subclip_videos[video_script['timestamp']]
|
video_script['path'] = subclip_videos[video_script['timestamp']]
|
||||||
except KeyError as err:
|
except KeyError as err:
|
||||||
logger.error(f"裁剪视频失败: {err}")
|
logger.error(f"裁剪视频失败: {err}")
|
||||||
# raise ValueError(f"裁剪视频失败: {err}")
|
|
||||||
|
|
||||||
return task_id, subclip_videos
|
return task_id, subclip_videos
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import streamlit as st
|
|||||||
import os
|
import os
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
|
||||||
def render_review_panel(tr):
|
def render_review_panel(tr):
|
||||||
"""渲染视频审查面板"""
|
"""渲染视频审查面板"""
|
||||||
with st.expander(tr("Video Check"), expanded=False):
|
with st.expander(tr("Video Check"), expanded=False):
|
||||||
@ -26,6 +27,7 @@ def render_review_panel(tr):
|
|||||||
with cols[col]:
|
with cols[col]:
|
||||||
render_video_item(tr, video_list, subclip_videos, index)
|
render_video_item(tr, video_list, subclip_videos, index)
|
||||||
|
|
||||||
|
|
||||||
def render_video_item(tr, video_list, subclip_videos, index):
|
def render_video_item(tr, video_list, subclip_videos, index):
|
||||||
"""渲染单个视频项"""
|
"""渲染单个视频项"""
|
||||||
video_script = video_list[index]
|
video_script = video_list[index]
|
||||||
@ -75,11 +77,12 @@ def render_video_item(tr, video_list, subclip_videos, index):
|
|||||||
# 显示剪辑模式
|
# 显示剪辑模式
|
||||||
ost = st.selectbox(
|
ost = st.selectbox(
|
||||||
tr("Clip Mode"),
|
tr("Clip Mode"),
|
||||||
options=range(1, 10),
|
options=range(0, 3),
|
||||||
index=video_script.get('OST', 1) - 1,
|
index=video_script.get('OST', 0),
|
||||||
key=f"ost_{index}"
|
key=f"ost_{index}",
|
||||||
|
help=tr("0: Keep the audio only, 1: Keep the original sound only, 2: Keep the original sound and audio")
|
||||||
)
|
)
|
||||||
# 保存修改后的剪辑模式
|
# 保存修改后的剪辑模式
|
||||||
if ost != video_script.get('OST', 1):
|
if ost != video_script.get('OST', 0):
|
||||||
video_script['OST'] = ost
|
video_script['OST'] = ost
|
||||||
st.session_state['video_clip_json'] = video_list
|
st.session_state['video_clip_json'] = video_list
|
||||||
@ -63,13 +63,11 @@
|
|||||||
"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": "你可以从以下链接下载生成的视频",
|
||||||
"Basic Settings": "**基础设置** (:blue[点击展开])",
|
"Basic Settings": "**基础设置** (:blue[点击展开])",
|
||||||
"Language": "界面语言",
|
|
||||||
"Pixabay API Key": "Pixabay API Key ([点击获取](https://pixabay.com/api/docs/#api_search_videos)) :red[可以不用配置,如果 Pexels 无法使用,再选择Pixabay]",
|
"Pixabay API Key": "Pixabay API Key ([点击获取](https://pixabay.com/api/docs/#api_search_videos)) :red[可以不用配置,如果 Pexels 无法使用,再选择Pixabay]",
|
||||||
"Video LLM Provider": "视频转录大模型",
|
"Video LLM Provider": "视频转录大模型",
|
||||||
"LLM Provider": "大语言模型",
|
"LLM Provider": "大语言模型",
|
||||||
"API Key": "API Key (:red[必填,需要到大模型提供商的后台申请])",
|
"API Key": "API Key (:red[必填,需要到大模型提供商的后台申请])",
|
||||||
"Base Url": "Base Url (可选)",
|
"Base Url": "Base Url (可选)",
|
||||||
"Account ID": "账户ID (Cloudflare的dash面板url中获取)",
|
|
||||||
"Model Name": "模型名称 (:blue[需要到大模型提供商的后台确认被授权的模型名称])",
|
"Model Name": "模型名称 (:blue[需要到大模型提供商的后台确认被授权的模型名称])",
|
||||||
"Please Enter the LLM API Key": "请先填写大模型 **API Key**",
|
"Please Enter the LLM API Key": "请先填写大模型 **API Key**",
|
||||||
"Please Enter the Pixabay API Key": "请先填写 **Pixabay API Key**",
|
"Please Enter the Pixabay API Key": "请先填写 **Pixabay API Key**",
|
||||||
@ -104,7 +102,6 @@
|
|||||||
"Video Script": "视频脚本",
|
"Video Script": "视频脚本",
|
||||||
"Video Quality": "视频质量",
|
"Video Quality": "视频质量",
|
||||||
"Custom prompt for LLM, leave empty to use default prompt": "自定义提示词,留空则使用默认提示词",
|
"Custom prompt for LLM, leave empty to use default prompt": "自定义提示词,留空则使用默认提示词",
|
||||||
"Basic Settings": "基础设置",
|
|
||||||
"Proxy Settings": "代理设置",
|
"Proxy Settings": "代理设置",
|
||||||
"Language": "界面语言",
|
"Language": "界面语言",
|
||||||
"HTTP_PROXY": "HTTP 代理",
|
"HTTP_PROXY": "HTTP 代理",
|
||||||
@ -134,6 +131,7 @@
|
|||||||
"gemini model is not available": "Gemini 模型不可用",
|
"gemini model is not available": "Gemini 模型不可用",
|
||||||
"NarratoAPI is available": "NarratoAPI 可用",
|
"NarratoAPI is available": "NarratoAPI 可用",
|
||||||
"NarratoAPI is not available": "NarratoAPI 不可用",
|
"NarratoAPI is not available": "NarratoAPI 不可用",
|
||||||
"Unsupported provider": "不支持的提供商"
|
"Unsupported provider": "不支持的提供商",
|
||||||
|
"0: Keep the audio only, 1: Keep the original sound only, 2: Keep the original sound and audio": "0: 仅保留音频,1: 仅保留原声,2: 保留原声和音频"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user