NarratoAI/app/services/SDP/generate_script_short.py
linyq 6cd1ff8b68 refactor(tools): 移除调试日志和未使用的参数- 在 base.py 中移除了调试日志,以减少日志噪音
- 在 generate_script_short.py 中移除了未使用的参数,简化了 API 调用
2025-05-10 23:57:15 +08:00

38 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
视频脚本生成pipeline串联各个处理步骤
"""
import os
from .utils.step1_subtitle_analyzer_openai import analyze_subtitle
from .utils.step5_merge_script import merge_script
def generate_script(srt_path: str, api_key: str, model_name: str, output_path: str, base_url: str = None, custom_clips: int = 5):
"""生成视频混剪脚本
Args:
srt_path: 字幕文件路径
output_path: 输出文件路径,可选
Returns:
str: 生成的脚本内容
"""
# 验证输入文件
if not os.path.exists(srt_path):
raise FileNotFoundError(f"字幕文件不存在: {srt_path}")
# 分析字幕
print("开始分析...")
openai_analysis = analyze_subtitle(
srt_path=srt_path,
api_key=api_key,
model_name=model_name,
base_url=base_url,
custom_clips=custom_clips
)
# 合并生成最终脚本
adjusted_results = openai_analysis['plot_points']
final_script = merge_script(adjusted_results, output_path)
return final_script