-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
156 lines (121 loc) · 5.11 KB
/
Copy pathexample_usage.py
File metadata and controls
156 lines (121 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env python3
"""
Example usage of AI Video Generation System.
This script demonstrates how to use the system programmatically.
"""
import os
import sys
from pathlib import Path
# Add src directory to path
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
def create_sample_script():
"""Create a sample script for testing."""
script_content = """
FADE IN:
INT. COFFEE SHOP - MORNING
The bustling coffee shop is filled with morning commuters. The aroma of freshly brewed coffee fills the air.
SARAH, a determined young woman in her late 20s, sits at a corner table with her laptop open. She's focused and typing rapidly.
SARAH
(muttering to herself)
This presentation has to be perfect. My entire career depends on it.
A barista approaches with her order.
BARISTA
(cheerful)
One large cappuccino for Sarah!
SARAH
(looking up, grateful)
Thank you so much. You're a lifesaver.
She takes a sip and returns to her work, more confident now.
CUT TO:
INT. OFFICE CONFERENCE ROOM - LATER
SARAH stands at the front of a conference room, presenting to a panel of executives.
SARAH
(confident, professional)
And that's why I believe this strategy will increase our market share by 25% in the next quarter.
The executives nod approvingly.
FADE OUT.
"""
script_path = "sample_script.txt"
with open(script_path, 'w') as f:
f.write(script_content)
return script_path
def main():
"""Run example usage."""
print("AI Video Generation System - Example Usage")
print("=" * 50)
try:
# Import modules
from config import config
from database import db_manager
from script_parser import ScriptParser
from character_generator import CharacterGenerator
from storyboard_analyzer import StoryboardAnalyzer
from video_generator import VideoGenerator
print("✓ All modules imported successfully")
# Create sample script
print("\n1. Creating sample script...")
script_path = create_sample_script()
print(f"✓ Created sample script: {script_path}")
# Create project
print("\n2. Creating project...")
project_id = db_manager.create_project("Sample Movie", script_path)
print(f"✓ Created project with ID: {project_id}")
# Parse script
print("\n3. Parsing script...")
parser = ScriptParser()
characters, scenes = parser.parse_script(script_path)
print(f"✓ Found {len(characters)} characters and {len(scenes)} scenes")
# Display characters
print("\nCharacters found:")
for char in characters:
print(f" - {char.name}: {char.description[:50]}... (importance: {char.importance_score:.2f})")
# Save characters to database
print("\n4. Saving characters to database...")
for char in characters:
char_id = db_manager.create_character(
project_id=project_id,
name=char.name,
description=char.description,
traits=char.traits,
importance_score=char.importance_score
)
print(f"✓ Saved character: {char.name} (ID: {char_id})")
# Save scenes to database
print("\n5. Saving scenes to database...")
for scene in scenes:
scene_id = db_manager.create_scene(
project_id=project_id,
scene_number=scene.scene_number,
header=scene.header,
description=scene.description,
dialogue=str(scene.dialogue),
action=str(scene.action),
camera_notes=str(scene.camera_notes),
emotions=scene.emotions
)
print(f"✓ Saved scene {scene.scene_number}: {scene.header}")
# Get project summary
print("\n6. Project summary:")
summary = db_manager.get_project_summary(project_id)
print(f" - Characters: {summary['character_count']}")
print(f" - Scenes: {summary['scene_count']}")
print(f" - Videos: {summary['video_count']}")
# Note about character generation and video generation
print("\n7. Next steps:")
print(" - Run: python src/main.py generate-references --project-id", project_id)
print(" - Run: python src/main.py analyze-storyboard --project-id", project_id, "--storyboard storyboard.png")
print(" - Run: python src/main.py generate-video --project-id", project_id)
print("\n✓ Example completed successfully!")
except Exception as e:
print(f"\n❌ Error: {e}")
import traceback
traceback.print_exc()
return 1
finally:
# Clean up
if 'script_path' in locals() and os.path.exists(script_path):
os.unlink(script_path)
print(f"\n✓ Cleaned up sample script")
return 0
if __name__ == "__main__":
sys.exit(main())