AI-video-lifeplan-demo/backend/simplify_intro.py

68 lines
2.2 KiB
Python

import json
from pathlib import Path
def simplify_intro():
props_path = Path("assets/1_processed/render_props.json")
if not props_path.exists():
print("Error: render_props.json not found")
return
with open(props_path, "r", encoding="utf-8") as f:
props = json.load(f)
script = props.get("script", [])
if len(script) < 6:
print("Script too short to simplify")
return
# Combined FP Segment (ID 1)
# Merging content from original 1, 3, 5
fp_text = "お客様のライフプランを提供するために、お名前と生年月日などの基本情報を教えていただけますでしょうか。"
fp_segment = {
"id": 1,
"text": fp_text,
"insight": "基本情報のヒアリング",
"targetYear": 2024,
"duration": 6.5, # Estimated, rebuild_audio will fix it
"type": "dialogue",
"visualType": "dialogue",
"speaker": "FP",
"brollKeyword": "Japanese financial advisor consulting client",
"audioPath": "public/segment_001.mp3"
}
# Combined Client Segment (ID 2)
# Merging content from original 2, 4, 6
client_text = "はい、テスト太郎です。1980年1月1日生まれの47歳です。"
client_segment = {
"id": 2,
"text": client_text,
"insight": "自己紹介と基本情報",
"targetYear": 2024,
"duration": 8.0, # Estimated
"type": "dialogue",
"visualType": "dialogue",
"speaker": "家族代表様",
"brollKeyword": "Japanese man introduced himself",
"audioPath": "public/segment_002.mp3" # Will use TTS for this combined one for now
}
# New script starts with these two
new_script = [fp_segment, client_segment]
# Append the rest (starting from original index 6, which is ID 7)
for i, seg in enumerate(script[6:]):
seg["id"] = i + 3
# We'll let rebuild_audio fix the paths and durations
new_script.append(seg)
props["script"] = new_script
with open(props_path, "w", encoding="utf-8") as f:
json.dump(props, f, ensure_ascii=False, indent=2)
print("Successfully simplified intro dialogue in render_props.json")
if __name__ == "__main__":
simplify_intro()