72 lines
2.4 KiB
Python
72 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
测试完整字幕和封面生成
|
|
"""
|
|
|
|
import os
|
|
import json
|
|
import sys
|
|
|
|
# 配置信息
|
|
CONFIG = {
|
|
"videoPath": r"C:\Users\Administrator\Desktop\视频生成\对比结果\121212.mp4",
|
|
"scriptText": "今天天气真好!\n明天下雨。\n我们去公园玩吧。\n这个电影太好看了。\n质量不好,我很失望。",
|
|
"subtitleStyle": "emotion-mixed", # 使用情感混合模式
|
|
"coverStyle": "default",
|
|
"outputDir": r"C:\Users\Administrator\AppData\Roaming\aigcpanel\data\temp\test_full_generation",
|
|
"useFunasr": False,
|
|
"coverOnly": False
|
|
}
|
|
|
|
def main():
|
|
print("=" * 60)
|
|
print("测试完整字幕和封面生成")
|
|
print("=" * 60)
|
|
|
|
# 确保输出目录存在
|
|
os.makedirs(CONFIG["outputDir"], exist_ok=True)
|
|
|
|
# 保存配置文件
|
|
config_path = os.path.join(CONFIG["outputDir"], "config.json")
|
|
with open(config_path, 'w', encoding='utf-8') as f:
|
|
json.dump(CONFIG, f, ensure_ascii=False, indent=2)
|
|
|
|
print(f"\n配置文件已保存: {config_path}")
|
|
print("\n开始生成...\n")
|
|
|
|
# 调用字幕生成器
|
|
from subtitle_cover_generator_simple import SubtitleCoverGenerator
|
|
|
|
generator = SubtitleCoverGenerator(CONFIG)
|
|
result = generator.generate_all()
|
|
|
|
print("\n" + "=" * 60)
|
|
print("生成结果:")
|
|
print("=" * 60)
|
|
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
|
|
if result['success']:
|
|
print("\n✓ 生成成功!")
|
|
print(f"\n封面路径: {result.get('coverPath')}")
|
|
print(f"视频路径: {result.get('videoPath')}")
|
|
print(f"\nNLP分析结果:")
|
|
print(f" 标题: {result['nlpAnalysis'].get('title')}")
|
|
print(f" 关键词: {result['nlpAnalysis'].get('keywords')}")
|
|
print(f" 情感: {result['nlpAnalysis'].get('sentiment')} (分数: {result['nlpAnalysis'].get('sentiment_score', 0):.4f})")
|
|
print(f"\n字幕数量: {len(result.get('subtitles', []))}")
|
|
|
|
# 打印每个字幕的情感和样式
|
|
print("\n字幕详情:")
|
|
for i, subtitle in enumerate(result.get('subtitles', []), 1):
|
|
print(f" {i}. {subtitle['text']}")
|
|
print(f" 情感: {subtitle['sentiment']} (分数: {subtitle['sentiment_score']:.4f}) -> 样式: {subtitle['style']}")
|
|
|
|
return 0
|
|
else:
|
|
print(f"\n✗ 生成失败: {result.get('error')}")
|
|
return 1
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|