nniehaus commited on
Commit
043548d
Β·
verified Β·
1 Parent(s): 8d3cc4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +369 -76
app.py CHANGED
@@ -1,10 +1,15 @@
1
  import streamlit as st
2
- import openai
3
  import os
 
 
 
 
 
4
 
5
  # Page configuration
6
  st.set_page_config(
7
- page_title="AI Video Script Generator",
8
  page_icon="🎬",
9
  layout="wide",
10
  initial_sidebar_state="collapsed"
@@ -71,49 +76,142 @@ st.markdown("""
71
  transform: translateY(-2px);
72
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
73
  }
 
 
 
 
 
 
 
 
74
  </style>
75
  """, unsafe_allow_html=True)
76
 
77
- # Initialize OpenAI API key
78
- openai.api_key = os.getenv("OPENAI_API_KEY")
 
 
 
 
 
 
 
 
79
 
80
- # Function to generate script with OpenAI API
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  def generate_video_script(prompt_data):
82
- if not openai.api_key:
83
- st.error("Please set your OPENAI_API_KEY environment variable")
84
  return None
85
 
86
  try:
 
 
 
 
 
87
  system_message = f"""
88
- You are an expert video marketing scriptwriter specializing in promotional content for businesses.
89
- You create compelling scripts that:
90
- - Hook viewers in the first 3 seconds
91
- - Tell a clear story about the business value
92
- - Build emotional connection with the audience
93
- - End with a powerful call-to-action
94
- - Use {prompt_data['tone'].lower()} tone throughout
 
 
 
95
 
96
- Your scripts contain ONLY the words to be spoken - no directions, no scene descriptions,
97
- just the exact dialogue for a promotional video.
 
 
 
98
  """
99
 
100
  user_message = f"""
101
  Create a promotional video script with these details:
102
 
103
- Business: {prompt_data['business']}
104
- Problem Solved: {prompt_data['problem']}
105
- Services: {prompt_data['services']}
106
- Unique Value: {prompt_data['unique']}
107
- Business Name: {prompt_data['name']}
108
- Call to Action: {prompt_data['cta']}
109
- Script Length: Maximum {prompt_data['length']} words
110
- Video Type: {prompt_data['video_type']}
111
- Target Audience: {prompt_data['audience']}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
- Make it {prompt_data['tone'].lower()} and ensure it's compelling from start to finish.
114
  """
115
 
116
- response = openai.ChatCompletion.create(
117
  model="gpt-4",
118
  messages=[
119
  {"role": "system", "content": system_message},
@@ -122,30 +220,70 @@ def generate_video_script(prompt_data):
122
  temperature=0.8
123
  )
124
 
125
- return response["choices"][0]["message"]["content"]
126
 
127
  except Exception as e:
128
  st.error(f"Error generating script: {str(e)}")
129
  return None
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  # Initialize session state
132
  if 'generated_script' not in st.session_state:
133
  st.session_state.generated_script = ""
134
  if 'show_form' not in st.session_state:
135
  st.session_state.show_form = True
 
 
136
 
137
  # Header
138
- st.markdown('<h1 class="main-header">🎬 AI Video Script Generator</h1>', unsafe_allow_html=True)
139
- st.markdown('<p class="sub-header">Create compelling promotional videos that convert viewers into customers</p>', unsafe_allow_html=True)
140
 
141
  # Benefits section
142
  st.markdown("""
143
  <div class="highlight-box">
144
- <h3>πŸ“ˆ Why Video Marketing Works</h3>
145
- <p>β€’ 87% of businesses use video as a marketing tool<br>
146
  β€’ Videos increase engagement by 1200% compared to text<br>
147
- β€’ 64% of customers make a purchase after watching a video<br>
148
- β€’ Get professional scripts in under 60 seconds!</p>
 
149
  </div>
150
  """, unsafe_allow_html=True)
151
 
@@ -165,13 +303,13 @@ if st.session_state.show_form:
165
  )
166
 
167
  problem_solved = st.text_input(
168
- "What problem do you solve for customers?",
169
  placeholder="e.g., We help busy professionals get amazing coffee without the wait",
170
- help="Focus on the main pain point you address"
171
  )
172
 
173
  services_offered = st.text_input(
174
- "What specific services/products should we highlight?",
175
  placeholder="e.g., Custom coffee subscriptions, corporate catering, barista training",
176
  help="List 2-3 key offerings you want to promote"
177
  )
@@ -179,7 +317,7 @@ if st.session_state.show_form:
179
  unique_aspects = st.text_input(
180
  "What makes you different from competitors?",
181
  placeholder="e.g., Only coffee shop in town with beans roasted daily on-site",
182
- help="Your unique selling proposition"
183
  )
184
 
185
  name_to_include = st.text_input(
@@ -189,27 +327,59 @@ if st.session_state.show_form:
189
  )
190
 
191
  call_to_action = st.text_input(
192
- "How should viewers contact you?",
193
  placeholder="e.g., Visit us at 123 Main Street or order online at our website",
194
- help="One clear action you want viewers to take"
195
  )
196
 
197
  with col2:
198
- st.markdown('<h2 class="section-header">🎯 Customize Your Script</h2>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
  video_type = st.selectbox(
201
  "Video Type:",
202
  [
203
- "Social Media Ad (Instagram/TikTok)",
204
- "YouTube Promotional Video",
205
- "Website Homepage Video",
206
- "Facebook/LinkedIn Ad",
207
- "Product Showcase",
208
- "Customer Testimonial Style",
209
  "Behind-the-Scenes",
210
- "Educational/How-To"
 
 
 
211
  ],
212
- help="Choose the platform or style you're targeting"
213
  )
214
 
215
  target_audience = st.selectbox(
@@ -224,22 +394,68 @@ if st.session_state.show_form:
224
  "Health-Conscious Consumers",
225
  "Luxury Market",
226
  "Budget-Conscious Shoppers",
227
- "General Audience"
228
  ],
229
  help="Who are you trying to reach?"
230
  )
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  tone_options = [
233
  "Professional & Trustworthy",
234
  "Friendly & Conversational",
235
  "Exciting & Energetic",
236
  "Warm & Personal",
237
  "Confident & Bold",
238
- "Humorous & Fun",
239
  "Inspiring & Motivational",
240
  "Urgent & Persuasive",
241
- "Calm & Reassuring",
242
- "Expert & Educational"
243
  ]
244
 
245
  tone = st.selectbox("Script Tone:", tone_options, help="How do you want to sound?")
@@ -253,13 +469,21 @@ if st.session_state.show_form:
253
  help="Shorter = social media, Longer = detailed explanations"
254
  )
255
 
256
- # Length guide
257
- st.markdown("""
 
 
 
 
 
 
 
 
 
 
258
  <div class="feature-box">
259
- <strong>πŸ“ Length Guide:</strong><br>
260
- β€’ 50-100 words: Quick social media ad<br>
261
- β€’ 100-200 words: Standard promotional video<br>
262
- β€’ 200-300 words: Detailed explanation video
263
  </div>
264
  """, unsafe_allow_html=True)
265
 
@@ -267,7 +491,7 @@ if st.session_state.show_form:
267
  st.markdown("<br>", unsafe_allow_html=True)
268
  col1, col2, col3 = st.columns([1, 2, 1])
269
  with col2:
270
- if st.button("πŸš€ Generate My Video Script", use_container_width=True):
271
  # Validation
272
  required_fields = [
273
  business_description, problem_solved, services_offered,
@@ -277,7 +501,7 @@ if st.session_state.show_form:
277
  if not all(required_fields):
278
  st.error("⚠️ Please fill in all required fields to generate your script.")
279
  else:
280
- with st.spinner("🎬 Crafting your perfect video script..."):
281
  prompt_data = {
282
  'business': business_description,
283
  'problem': problem_solved,
@@ -287,19 +511,42 @@ if st.session_state.show_form:
287
  'cta': call_to_action,
288
  'length': script_length,
289
  'tone': tone,
 
290
  'video_type': video_type,
291
- 'audience': target_audience
 
 
 
292
  }
293
 
294
  script = generate_video_script(prompt_data)
295
  if script:
296
  st.session_state.generated_script = script
 
 
 
 
 
 
 
 
 
297
  st.session_state.show_form = False
298
  st.rerun()
299
 
300
  # Display generated script
301
  if st.session_state.generated_script and not st.session_state.show_form:
302
- st.markdown('<h2 class="section-header">🎬 Your Video Script is Ready!</h2>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
303
 
304
  # Script display
305
  formatted_script = st.session_state.generated_script.replace('\n', '<br>')
@@ -313,38 +560,84 @@ if st.session_state.generated_script and not st.session_state.show_form:
313
  """, unsafe_allow_html=True)
314
 
315
  # Action buttons
316
- col1, col2, col3 = st.columns([1, 1, 1])
317
 
318
  with col1:
319
  st.download_button(
320
- label="πŸ“₯ Download Script",
321
  data=st.session_state.generated_script,
322
- file_name=f"video_script_{name_to_include.replace(' ', '_').lower()}.txt",
323
  mime="text/plain",
324
  use_container_width=True
325
  )
326
 
327
  with col2:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  if st.button("✏️ Edit Details", use_container_width=True):
329
  st.session_state.show_form = True
330
  st.rerun()
331
 
332
- with col3:
333
  if st.button("πŸ”„ Generate New Script", use_container_width=True):
334
  st.session_state.generated_script = ""
 
335
  st.session_state.show_form = True
336
  st.rerun()
337
 
338
- # Tips section
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  st.markdown("""
340
  <div class="feature-box">
341
- <h4>🎯 Tips for Recording Your Video:</h4>
342
- β€’ Practice reading the script 2-3 times before recording<br>
343
- β€’ Speak clearly and at a moderate pace<br>
344
- β€’ Maintain eye contact with the camera<br>
345
- β€’ Use good lighting (face the light source)<br>
346
- β€’ Keep background simple and professional<br>
347
- β€’ Record multiple takes and choose the best one
348
  </div>
349
  """, unsafe_allow_html=True)
350
 
@@ -352,6 +645,6 @@ if st.session_state.generated_script and not st.session_state.show_form:
352
  st.markdown("<br><br>", unsafe_allow_html=True)
353
  st.markdown("""
354
  <div style="text-align: center; color: #666; padding: 2rem;">
355
- <p>🎬 Ready to create videos that convert? Generate unlimited scripts and grow your business!</p>
356
  </div>
357
  """, unsafe_allow_html=True)
 
1
  import streamlit as st
2
+ from openai import OpenAI
3
  import os
4
+ from reportlab.lib.pagesizes import letter
5
+ from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
6
+ from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
7
+ from reportlab.lib.units import inch
8
+ import io
9
 
10
  # Page configuration
11
  st.set_page_config(
12
+ page_title="AI Video Script Generator Pro",
13
  page_icon="🎬",
14
  layout="wide",
15
  initial_sidebar_state="collapsed"
 
76
  transform: translateY(-2px);
77
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
78
  }
79
+ .platform-tips {
80
+ background: #e8f4fd;
81
+ padding: 1rem;
82
+ border-radius: 8px;
83
+ border-left: 4px solid #2196F3;
84
+ margin: 1rem 0;
85
+ font-size: 0.9rem;
86
+ }
87
  </style>
88
  """, unsafe_allow_html=True)
89
 
90
+ # Initialize OpenAI client
91
+ @st.cache_resource
92
+ def get_openai_client():
93
+ api_key = os.getenv("OPENAI_API_KEY")
94
+ if not api_key:
95
+ st.error("Please set your OPENAI_API_KEY environment variable")
96
+ return None
97
+ return OpenAI(api_key=api_key)
98
+
99
+ client = get_openai_client()
100
 
101
+ # Function to generate PDF
102
+ def create_pdf(script_content, business_name, platform, video_type):
103
+ buffer = io.BytesIO()
104
+ doc = SimpleDocTemplate(buffer, pagesize=letter, topMargin=1*inch)
105
+
106
+ # Define styles
107
+ styles = getSampleStyleSheet()
108
+ title_style = ParagraphStyle(
109
+ 'CustomTitle',
110
+ parent=styles['Heading1'],
111
+ fontSize=18,
112
+ textColor='#1f4e79',
113
+ alignment=1, # Center alignment
114
+ spaceAfter=30
115
+ )
116
+
117
+ content_style = ParagraphStyle(
118
+ 'CustomContent',
119
+ parent=styles['Normal'],
120
+ fontSize=12,
121
+ leading=18,
122
+ spaceAfter=12
123
+ )
124
+
125
+ # Create content
126
+ story = []
127
+
128
+ # Title
129
+ story.append(Paragraph(f"Video Script for {business_name}", title_style))
130
+ story.append(Spacer(1, 20))
131
+
132
+ # Details
133
+ story.append(Paragraph(f"<b>Platform:</b> {platform}", content_style))
134
+ story.append(Paragraph(f"<b>Video Type:</b> {video_type}", content_style))
135
+ story.append(Spacer(1, 20))
136
+
137
+ # Script content
138
+ story.append(Paragraph("<b>Script:</b>", content_style))
139
+ story.append(Spacer(1, 10))
140
+
141
+ # Clean and format script content
142
+ script_paragraphs = script_content.split('\n')
143
+ for paragraph in script_paragraphs:
144
+ if paragraph.strip():
145
+ story.append(Paragraph(paragraph.strip(), content_style))
146
+
147
+ # Build PDF
148
+ doc.build(story)
149
+ buffer.seek(0)
150
+ return buffer
151
+
152
+ # Function to generate script with enhanced prompting
153
  def generate_video_script(prompt_data):
154
+ if not client:
 
155
  return None
156
 
157
  try:
158
+ # Get platform-specific requirements
159
+ platform_reqs = get_platform_requirements(prompt_data['platform'])
160
+ hook_strategy = get_hook_strategy(prompt_data['hook_type'])
161
+ storytelling_framework = get_storytelling_framework(prompt_data['storytelling'])
162
+
163
  system_message = f"""
164
+ You are an expert video marketing strategist who creates compelling promotional scripts that convert viewers into customers. Your scripts are based on 2024-2025 research showing that authenticity beats polish, and that 93% of marketers see good ROI from video marketing.
165
+
166
+ CRITICAL REQUIREMENTS:
167
+ - Hook viewers in the first 3-5 seconds using psychological triggers
168
+ - Create authentic, conversational content that blends with organic social media
169
+ - Address specific customer pain points with empathy and understanding
170
+ - Use proven storytelling frameworks for maximum engagement
171
+ - Include strong, specific call-to-actions that drive conversions
172
+ - Optimize for platform-specific requirements and audience behaviors
173
+ - Write ONLY the words to be spoken - no directions or stage notes
174
 
175
+ Platform Requirements: {platform_reqs}
176
+ Hook Strategy: {hook_strategy}
177
+ Storytelling Framework: {storytelling_framework}
178
+
179
+ The script should feel natural, authentic, and valuable to the viewer even if they don't buy anything.
180
  """
181
 
182
  user_message = f"""
183
  Create a promotional video script with these details:
184
 
185
+ BUSINESS INFO:
186
+ - Business: {prompt_data['business']}
187
+ - Problem Solved: {prompt_data['problem']}
188
+ - Services/Products: {prompt_data['services']}
189
+ - Unique Value: {prompt_data['unique']}
190
+ - Business Name: {prompt_data['name']}
191
+ - Target Audience: {prompt_data['audience']}
192
+
193
+ VIDEO SPECIFICATIONS:
194
+ - Platform: {prompt_data['platform']}
195
+ - Video Type: {prompt_data['video_type']}
196
+ - Script Length: Maximum {prompt_data['length']} words
197
+ - Tone: {prompt_data['tone']}
198
+ - Hook Type: {prompt_data['hook_type']}
199
+ - Storytelling Framework: {prompt_data['storytelling']}
200
+ - Call to Action: {prompt_data['cta']}
201
+
202
+ PSYCHOLOGICAL TRIGGERS TO INCLUDE:
203
+ - {prompt_data['psychological_triggers']}
204
+
205
+ Follow this structure:
206
+ 1. HOOK (0-5 seconds): Use {prompt_data['hook_type']} approach to stop scrolling
207
+ 2. PROBLEM/CONTEXT (5-15 seconds): Address the specific pain point with empathy
208
+ 3. SOLUTION/VALUE (15-45 seconds): Present your solution using {prompt_data['storytelling']} framework
209
+ 4. CALL-TO-ACTION (45-60 seconds): Clear, specific action with urgency
210
 
211
+ Make it authentic, conversational, and optimized for {prompt_data['platform']} consumption patterns.
212
  """
213
 
214
+ response = client.chat.completions.create(
215
  model="gpt-4",
216
  messages=[
217
  {"role": "system", "content": system_message},
 
220
  temperature=0.8
221
  )
222
 
223
+ return response.choices[0].message.content
224
 
225
  except Exception as e:
226
  st.error(f"Error generating script: {str(e)}")
227
  return None
228
 
229
+ def get_platform_requirements(platform):
230
+ platform_specs = {
231
+ "Instagram Reels": "Vertical 9:16 format, 15-90 seconds optimal, trending audio integration crucial, captions required for 75% silent viewing, hook in first 3 seconds critical for algorithm",
232
+ "TikTok": "31-60 seconds optimal (42.7s average), vertical format essential, completion rate prioritized by algorithm, native feel crucial, trending sounds boost reach",
233
+ "YouTube Shorts": "Up to 3 minutes allowed, vertical 9:16 format, mobile-first consumption, separate Shorts feed optimization, focus on educational value",
234
+ "LinkedIn": "30 seconds to 2 minutes, professional educational tone, business relevance essential, native uploads preferred, B2B audience focus",
235
+ "Facebook": "Native uploads over shared links, 74% watched without sound (captions essential), meaningful social interactions prioritized, 1-3 minutes optimal",
236
+ "Twitter/X": "15 seconds or less optimal for completion, 2:20 maximum, real-time trending integration valuable, concise messaging essential",
237
+ "Email Marketing": "1-2 minutes maximum, static thumbnail with play button, clear value proposition in preview, fallback content for unsupported clients"
238
+ }
239
+ return platform_specs.get(platform, "General social media optimization")
240
+
241
+ def get_hook_strategy(hook_type):
242
+ hook_strategies = {
243
+ "Question Hook": "Start with a compelling question that addresses a specific pain point or desire, creating curiosity gaps that compel continued viewing",
244
+ "Movement Hook": "Begin with dynamic visual action - phone in hand, grabbing props, or physical movement that creates pattern interrupts",
245
+ "Direct Call-out": "Use attention-grabbing phrases like 'Stop scrolling!' combined with specific audience targeting for immediate relevance",
246
+ "Problem Statement": "Open by identifying a relatable, frustrating situation your audience experiences daily",
247
+ "Curiosity Gap": "Hint at valuable information without revealing everything, using phrases like 'What if I told you...'",
248
+ "Negative Hook": "Address mistakes or problems using loss aversion psychology - 'Stop making this mistake that's costing you...'",
249
+ "Statistical Hook": "Lead with surprising or compelling data that challenges assumptions or reveals insights",
250
+ "Story Hook": "Begin with a relatable personal anecdote or customer story that draws viewers into a narrative"
251
+ }
252
+ return hook_strategies.get(hook_type, "Create an attention-grabbing opening")
253
+
254
+ def get_storytelling_framework(framework):
255
+ frameworks = {
256
+ "Problem-Solution": "Identify specific problem (0-15s) β†’ Agitate consequences (15-30s) β†’ Present solution (30-45s) β†’ Show results (45-60s)",
257
+ "Before-After": "Show current frustrating situation β†’ Reveal transformation process β†’ Demonstrate improved outcomes with specific benefits",
258
+ "Hero's Journey": "Position customer as hero facing challenge β†’ Guide them through transformation β†’ Show achieved success state",
259
+ "Pixar Framework": "Character in routine β†’ Disruption occurs β†’ Consequences unfold β†’ Development happens β†’ Resolution achieved β†’ Clear moral",
260
+ "Educational Value": "Promise valuable learning β†’ Deliver actionable insights β†’ Demonstrate application β†’ Provide next steps",
261
+ "Testimonial Story": "Customer introduction β†’ Specific problem β†’ Solution application β†’ Tangible results achieved",
262
+ "Behind-the-Scenes": "Show authentic process β†’ Reveal human elements β†’ Build trust through transparency β†’ Connect with audience values"
263
+ }
264
+ return frameworks.get(framework, "Structure content for maximum engagement")
265
+
266
  # Initialize session state
267
  if 'generated_script' not in st.session_state:
268
  st.session_state.generated_script = ""
269
  if 'show_form' not in st.session_state:
270
  st.session_state.show_form = True
271
+ if 'script_metadata' not in st.session_state:
272
+ st.session_state.script_metadata = {}
273
 
274
  # Header
275
+ st.markdown('<h1 class="main-header">🎬 AI Video Script Generator Pro</h1>', unsafe_allow_html=True)
276
+ st.markdown('<p class="sub-header">Create authentic promotional videos that convert viewers into customers using 2024-2025 research insights</p>', unsafe_allow_html=True)
277
 
278
  # Benefits section
279
  st.markdown("""
280
  <div class="highlight-box">
281
+ <h3>πŸ“ˆ Why This Approach Works</h3>
282
+ <p>β€’ 93% of marketers report good ROI from video marketing<br>
283
  β€’ Videos increase engagement by 1200% compared to text<br>
284
+ β€’ 34% higher conversion rates with video content<br>
285
+ β€’ Authenticity beats production value in 2024-2025<br>
286
+ β€’ Platform-optimized scripts for maximum reach!</p>
287
  </div>
288
  """, unsafe_allow_html=True)
289
 
 
303
  )
304
 
305
  problem_solved = st.text_input(
306
+ "What specific problem do you solve for customers?",
307
  placeholder="e.g., We help busy professionals get amazing coffee without the wait",
308
+ help="Focus on the main pain point you address - be specific"
309
  )
310
 
311
  services_offered = st.text_input(
312
+ "What services/products should we highlight?",
313
  placeholder="e.g., Custom coffee subscriptions, corporate catering, barista training",
314
  help="List 2-3 key offerings you want to promote"
315
  )
 
317
  unique_aspects = st.text_input(
318
  "What makes you different from competitors?",
319
  placeholder="e.g., Only coffee shop in town with beans roasted daily on-site",
320
+ help="Your unique selling proposition that sets you apart"
321
  )
322
 
323
  name_to_include = st.text_input(
 
327
  )
328
 
329
  call_to_action = st.text_input(
330
+ "What specific action should viewers take?",
331
  placeholder="e.g., Visit us at 123 Main Street or order online at our website",
332
+ help="One clear, specific action you want viewers to take"
333
  )
334
 
335
  with col2:
336
+ st.markdown('<h2 class="section-header">🎯 Platform & Style Optimization</h2>', unsafe_allow_html=True)
337
+
338
+ platform = st.selectbox(
339
+ "Primary Platform:",
340
+ [
341
+ "Instagram Reels",
342
+ "TikTok",
343
+ "YouTube Shorts",
344
+ "LinkedIn",
345
+ "Facebook",
346
+ "Twitter/X",
347
+ "Email Marketing"
348
+ ],
349
+ help="Choose your main distribution platform for optimization"
350
+ )
351
+
352
+ # Platform-specific tips
353
+ platform_tips = {
354
+ "Instagram Reels": "πŸ“± Vertical format essential β€’ 15-90 seconds optimal β€’ Use trending audio β€’ Captions required",
355
+ "TikTok": "🎡 31-60 seconds works best β€’ Completion rate crucial β€’ Native feel important β€’ Trending sounds boost reach",
356
+ "YouTube Shorts": "πŸ“Ί Up to 3 minutes allowed β€’ Educational content performs well β€’ Mobile-first viewing",
357
+ "LinkedIn": "πŸ’Ό Professional tone essential β€’ 30 seconds-2 minutes β€’ Educational/business value focus",
358
+ "Facebook": "πŸ‘₯ Native uploads preferred β€’ 74% watch without sound β€’ Captions essential",
359
+ "Twitter/X": "⚑ 15 seconds optimal β€’ Real-time relevance β€’ Concise messaging",
360
+ "Email Marketing": "πŸ“§ 1-2 minutes max β€’ Clear thumbnail β€’ Value-focused preview"
361
+ }
362
+
363
+ st.markdown(f"""
364
+ <div class="platform-tips">
365
+ <strong>Platform Tips:</strong><br>
366
+ {platform_tips.get(platform, "General optimization tips")}
367
+ </div>
368
+ """, unsafe_allow_html=True)
369
 
370
  video_type = st.selectbox(
371
  "Video Type:",
372
  [
373
+ "Product/Service Showcase",
374
+ "Problem-Solution Focused",
375
+ "Educational/How-To",
 
 
 
376
  "Behind-the-Scenes",
377
+ "Customer Success Story",
378
+ "Brand Awareness",
379
+ "Promotional Offer",
380
+ "Comparison/Competition"
381
  ],
382
+ help="Choose the primary purpose of your video"
383
  )
384
 
385
  target_audience = st.selectbox(
 
394
  "Health-Conscious Consumers",
395
  "Luxury Market",
396
  "Budget-Conscious Shoppers",
397
+ "Industry Professionals"
398
  ],
399
  help="Who are you trying to reach?"
400
  )
401
 
402
+ # Advanced options
403
+ st.markdown('<h3 style="color: #1f4e79; margin-top: 1.5rem;">🧠 Psychology & Storytelling</h3>', unsafe_allow_html=True)
404
+
405
+ hook_type = st.selectbox(
406
+ "Hook Strategy:",
407
+ [
408
+ "Question Hook",
409
+ "Problem Statement",
410
+ "Curiosity Gap",
411
+ "Direct Call-out",
412
+ "Movement Hook",
413
+ "Negative Hook",
414
+ "Statistical Hook",
415
+ "Story Hook"
416
+ ],
417
+ help="How do you want to grab attention in the first 3-5 seconds?"
418
+ )
419
+
420
+ storytelling_framework = st.selectbox(
421
+ "Storytelling Framework:",
422
+ [
423
+ "Problem-Solution",
424
+ "Before-After",
425
+ "Hero's Journey",
426
+ "Educational Value",
427
+ "Testimonial Story",
428
+ "Behind-the-Scenes",
429
+ "Pixar Framework"
430
+ ],
431
+ help="Choose your narrative structure"
432
+ )
433
+
434
+ psychological_triggers = st.multiselect(
435
+ "Psychological Triggers:",
436
+ [
437
+ "Social Proof (testimonials, statistics)",
438
+ "Scarcity/FOMO (limited time, exclusive)",
439
+ "Authority (expert endorsement)",
440
+ "Reciprocity (free value first)",
441
+ "Curiosity (information gaps)",
442
+ "Empathy (shared experiences)",
443
+ "Urgency (immediate action needed)"
444
+ ],
445
+ default=["Social Proof (testimonials, statistics)", "Curiosity (information gaps)"],
446
+ help="Select psychological elements to include"
447
+ )
448
+
449
  tone_options = [
450
  "Professional & Trustworthy",
451
  "Friendly & Conversational",
452
  "Exciting & Energetic",
453
  "Warm & Personal",
454
  "Confident & Bold",
455
+ "Educational & Expert",
456
  "Inspiring & Motivational",
457
  "Urgent & Persuasive",
458
+ "Authentic & Real"
 
459
  ]
460
 
461
  tone = st.selectbox("Script Tone:", tone_options, help="How do you want to sound?")
 
469
  help="Shorter = social media, Longer = detailed explanations"
470
  )
471
 
472
+ # Length guide based on platform
473
+ length_guides = {
474
+ "Instagram Reels": "75-150 words (15-90 seconds)",
475
+ "TikTok": "75-125 words (31-60 seconds)",
476
+ "YouTube Shorts": "100-200 words (up to 3 minutes)",
477
+ "LinkedIn": "100-175 words (30 seconds-2 minutes)",
478
+ "Facebook": "100-200 words (1-3 minutes)",
479
+ "Twitter/X": "50-75 words (15 seconds optimal)",
480
+ "Email Marketing": "150-300 words (1-2 minutes)"
481
+ }
482
+
483
+ st.markdown(f"""
484
  <div class="feature-box">
485
+ <strong>πŸ“ Recommended for {platform}:</strong><br>
486
+ {length_guides.get(platform, "100-200 words for general use")}
 
 
487
  </div>
488
  """, unsafe_allow_html=True)
489
 
 
491
  st.markdown("<br>", unsafe_allow_html=True)
492
  col1, col2, col3 = st.columns([1, 2, 1])
493
  with col2:
494
+ if st.button("πŸš€ Generate My Optimized Video Script", use_container_width=True):
495
  # Validation
496
  required_fields = [
497
  business_description, problem_solved, services_offered,
 
501
  if not all(required_fields):
502
  st.error("⚠️ Please fill in all required fields to generate your script.")
503
  else:
504
+ with st.spinner("🎬 Crafting your conversion-optimized video script..."):
505
  prompt_data = {
506
  'business': business_description,
507
  'problem': problem_solved,
 
511
  'cta': call_to_action,
512
  'length': script_length,
513
  'tone': tone,
514
+ 'platform': platform,
515
  'video_type': video_type,
516
+ 'audience': target_audience,
517
+ 'hook_type': hook_type,
518
+ 'storytelling': storytelling_framework,
519
+ 'psychological_triggers': ", ".join(psychological_triggers)
520
  }
521
 
522
  script = generate_video_script(prompt_data)
523
  if script:
524
  st.session_state.generated_script = script
525
+ st.session_state.script_metadata = {
526
+ 'business_name': name_to_include,
527
+ 'platform': platform,
528
+ 'video_type': video_type,
529
+ 'length': script_length,
530
+ 'tone': tone,
531
+ 'hook_type': hook_type,
532
+ 'storytelling': storytelling_framework
533
+ }
534
  st.session_state.show_form = False
535
  st.rerun()
536
 
537
  # Display generated script
538
  if st.session_state.generated_script and not st.session_state.show_form:
539
+ st.markdown('<h2 class="section-header">🎬 Your Optimized Video Script is Ready!</h2>', unsafe_allow_html=True)
540
+
541
+ # Script metadata display
542
+ metadata = st.session_state.script_metadata
543
+ col1, col2, col3 = st.columns(3)
544
+ with col1:
545
+ st.metric("Platform", metadata.get('platform', 'N/A'))
546
+ with col2:
547
+ st.metric("Hook Strategy", metadata.get('hook_type', 'N/A'))
548
+ with col3:
549
+ st.metric("Length", f"{metadata.get('length', 'N/A')} words")
550
 
551
  # Script display
552
  formatted_script = st.session_state.generated_script.replace('\n', '<br>')
 
560
  """, unsafe_allow_html=True)
561
 
562
  # Action buttons
563
+ col1, col2, col3, col4 = st.columns([1, 1, 1, 1])
564
 
565
  with col1:
566
  st.download_button(
567
+ label="πŸ“₯ Download TXT",
568
  data=st.session_state.generated_script,
569
+ file_name=f"video_script_{metadata.get('business_name', 'business').replace(' ', '_').lower()}.txt",
570
  mime="text/plain",
571
  use_container_width=True
572
  )
573
 
574
  with col2:
575
+ # PDF download button
576
+ if st.button("πŸ“„ Download PDF", use_container_width=True):
577
+ pdf_buffer = create_pdf(
578
+ st.session_state.generated_script,
579
+ metadata.get('business_name', 'Your Business'),
580
+ metadata.get('platform', 'General'),
581
+ metadata.get('video_type', 'Promotional')
582
+ )
583
+
584
+ st.download_button(
585
+ label="πŸ“„ Download PDF",
586
+ data=pdf_buffer.getvalue(),
587
+ file_name=f"video_script_{metadata.get('business_name', 'business').replace(' ', '_').lower()}.pdf",
588
+ mime="application/pdf",
589
+ use_container_width=True,
590
+ key="pdf_download"
591
+ )
592
+
593
+ with col3:
594
  if st.button("✏️ Edit Details", use_container_width=True):
595
  st.session_state.show_form = True
596
  st.rerun()
597
 
598
+ with col4:
599
  if st.button("πŸ”„ Generate New Script", use_container_width=True):
600
  st.session_state.generated_script = ""
601
+ st.session_state.script_metadata = {}
602
  st.session_state.show_form = True
603
  st.rerun()
604
 
605
+ # Platform-specific tips for recording
606
+ platform_recording_tips = {
607
+ "Instagram Reels": "β€’ Record in vertical format (9:16) β€’ Use trending audio or original sound β€’ Add captions for accessibility β€’ Post when your audience is most active β€’ Use relevant hashtags",
608
+ "TikTok": "β€’ Keep it authentic and native-looking β€’ Use trending sounds when possible β€’ Focus on completion rate β€’ Engage with comments quickly β€’ Post consistently",
609
+ "YouTube Shorts": "β€’ Create compelling thumbnails β€’ Use YouTube Shorts hashtag β€’ Focus on educational value β€’ Optimize title and description β€’ Create playlist for shorts",
610
+ "LinkedIn": "β€’ Professional backdrop and attire β€’ Focus on business value β€’ Use industry-relevant hashtags β€’ Tag relevant connections β€’ Post during business hours",
611
+ "Facebook": "β€’ Upload natively to Facebook β€’ Include captions for silent viewing β€’ Use Facebook's video features β€’ Cross-post to appropriate groups β€’ Encourage meaningful comments",
612
+ "Twitter/X": "β€’ Keep it concise and punchy β€’ Use relevant trending hashtags β€’ Tweet at optimal times β€’ Engage with replies β€’ Consider Twitter Spaces for longer content",
613
+ "Email Marketing": "β€’ Create compelling thumbnail image β€’ Include clear play button β€’ Have fallback text for unsupported clients β€’ Keep file size under 10MB β€’ Test across email clients"
614
+ }
615
+
616
+ current_platform = metadata.get('platform', 'General')
617
+ recording_tips = platform_recording_tips.get(current_platform, "β€’ Practice reading the script 2-3 times β€’ Speak clearly and at moderate pace β€’ Maintain eye contact with camera β€’ Use good lighting β€’ Keep background simple")
618
+
619
+ st.markdown(f"""
620
+ <div class="feature-box">
621
+ <h4>🎯 Recording Tips for {current_platform}:</h4>
622
+ {recording_tips}<br><br>
623
+ <strong>Universal Best Practices:</strong><br>
624
+ β€’ Test your setup before final recording<br>
625
+ β€’ Record multiple takes and choose the best<br>
626
+ β€’ Ensure good audio quality<br>
627
+ β€’ Review for authenticity and energy
628
+ </div>
629
+ """, unsafe_allow_html=True)
630
+
631
+ # Performance optimization tips
632
  st.markdown("""
633
  <div class="feature-box">
634
+ <h4>πŸ“Š Maximize Your Video Performance:</h4>
635
+ β€’ Post when your audience is most active<br>
636
+ β€’ Respond to comments within the first hour<br>
637
+ β€’ Use platform-specific features (polls, stickers, etc.)<br>
638
+ β€’ Track completion rates and engagement metrics<br>
639
+ β€’ A/B test different hooks and CTAs<br>
640
+ β€’ Repurpose successful content across platforms
641
  </div>
642
  """, unsafe_allow_html=True)
643
 
 
645
  st.markdown("<br><br>", unsafe_allow_html=True)
646
  st.markdown("""
647
  <div style="text-align: center; color: #666; padding: 2rem;">
648
+ <p>🎬 Ready to create videos that convert? This tool uses 2024-2025 research insights to maximize your video marketing ROI!</p>
649
  </div>
650
  """, unsafe_allow_html=True)