Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
+
|
| 4 |
+
# Function to generate detailed and unique video screenplay
|
| 5 |
+
def generate_screenplay(client, product, brief, demographic, duration, frame_count, emotional_appeal, key_features, cta, location, music_genre, shot_type, visual_style, additional_input):
|
| 6 |
+
try:
|
| 7 |
+
# Divide total video duration by frame count to get approximate time per frame
|
| 8 |
+
duration_per_frame = float(duration) / int(frame_count)
|
| 9 |
+
screenplay = f"**Creative Strategy:** {client} - {product}\n\n"
|
| 10 |
+
screenplay += f"**Demographic:** {demographic}\n\n"
|
| 11 |
+
screenplay += f"**Creative Brief:** {brief}\n\n"
|
| 12 |
+
screenplay += f"**Emotional Appeal:** {emotional_appeal}\n\n"
|
| 13 |
+
screenplay += f"**Call to Action:** {cta}\n\n"
|
| 14 |
+
screenplay += "**Video Screenplay Breakdown:**\n"
|
| 15 |
+
|
| 16 |
+
# Generate unique details for each frame
|
| 17 |
+
for i in range(1, int(frame_count) + 1):
|
| 18 |
+
start_time = round((i - 1) * duration_per_frame, 2)
|
| 19 |
+
end_time = round(i * duration_per_frame, 2)
|
| 20 |
+
|
| 21 |
+
# Add variety to visual, music, and AI prompts
|
| 22 |
+
visual_options = [
|
| 23 |
+
f"A vibrant morning scene in a bustling {location}. The camera pans across a warm, golden-lit environment with people interacting joyfully. The protagonist, styled in contemporary business casual attire, confidently uses {product} against a backdrop of sleek urban architecture and lush greenery.",
|
| 24 |
+
f"An indoor setup with soft natural light streaming through large windows. The protagonist, dressed in pastel-colored formal wear, interacts with {product} placed on a polished wooden table. Minimalistic decor enhances the scene's sophistication.",
|
| 25 |
+
f"A cinematic close-up of {product}, placed elegantly on a textured surface. The backdrop features a blurred skyline with subtle movement, emphasizing depth. Vibrant colors like deep blues and gold highlight the product's premium appeal.",
|
| 26 |
+
f"A playful outdoor park setting with children laughing and playing in the background. The protagonist, casually dressed in bright colors, uses {product} to solve a relatable problem. Flowers and greenery add to the cheerful mood.",
|
| 27 |
+
f"A high-energy party scene with colorful lighting and dynamic camera angles. The protagonist, styled in trendy evening wear, showcases {product} as the center of attention. The vibrant environment reflects excitement and modernity."
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
music_options = [
|
| 31 |
+
f"Uplifting {music_genre} tune that crescendos to evoke {emotional_appeal.lower()}.",
|
| 32 |
+
f"A melodic {music_genre} soundtrack with subtle tones that perfectly complement the emotional appeal of {product}.",
|
| 33 |
+
f"Catchy and rhythmic {music_genre} designed to keep the audience engaged and connected.",
|
| 34 |
+
f"A gentle {music_genre} background score that matches the narrative's flow and {emotional_appeal.lower()}.",
|
| 35 |
+
f"High-energy {music_genre} that resonates with excitement and passion for {product}."
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
voiceover_options = [
|
| 39 |
+
f"An engaging voiceover narrating the story of {product} and its transformative impact on {demographic}.",
|
| 40 |
+
f"A warm and inviting tone explaining the features of {product} while emphasizing its relevance to {demographic}.",
|
| 41 |
+
f"A confident and persuasive voiceover delivering the emotional appeal: {emotional_appeal}.",
|
| 42 |
+
f"A story-like narration that connects with the audience, drawing them into the world of {product}.",
|
| 43 |
+
f"A direct and empowering voiceover emphasizing why {product} is the perfect choice for {demographic}."
|
| 44 |
+
]
|
| 45 |
+
|
| 46 |
+
ai_prompt_options = [
|
| 47 |
+
f"Generate a cinematic visual of {product} being used in a {location} setting, highlighting key features like {key_features}.",
|
| 48 |
+
f"Create a surreal and {visual_style} scene featuring {product} in an unexpected but delightful {location}.",
|
| 49 |
+
f"Develop a {visual_style} animation showing how {product} integrates seamlessly into {demographic}'s lifestyle.",
|
| 50 |
+
f"Craft a visually stunning montage of {product} with a focus on emotional appeal: {emotional_appeal}.",
|
| 51 |
+
f"Design an engaging visual that blends real-life usage of {product} in {location} with stylized elements."
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
# Add frame details
|
| 55 |
+
screenplay += f"**Frame {i}:**\n"
|
| 56 |
+
screenplay += f"- **Time:** {start_time}s to {end_time}s\n"
|
| 57 |
+
screenplay += f"- **Visual:** {random.choice(visual_options)}\n"
|
| 58 |
+
screenplay += f"- **Voiceover:** {random.choice(voiceover_options)}\n"
|
| 59 |
+
screenplay += f"- **Music:** {random.choice(music_options)}\n"
|
| 60 |
+
screenplay += f"- **AI Prompt:** {random.choice(ai_prompt_options)}\n\n"
|
| 61 |
+
|
| 62 |
+
screenplay += f"**Additional Input:** {additional_input}\n"
|
| 63 |
+
return screenplay
|
| 64 |
+
|
| 65 |
+
except Exception as e:
|
| 66 |
+
return f"Error: {e}"
|
| 67 |
+
|
| 68 |
+
# Gradio interface
|
| 69 |
+
iface = gr.Interface(
|
| 70 |
+
fn=generate_screenplay,
|
| 71 |
+
inputs=[
|
| 72 |
+
gr.Textbox(label="Client", placeholder="Enter the client's name (e.g., Elegant Shoes)"),
|
| 73 |
+
gr.Textbox(label="Product", placeholder="Enter the product name (e.g., Ladies High Heels)"),
|
| 74 |
+
gr.Textbox(label="Creative Brief", placeholder="Describe the creative brief (e.g., Elegance for working-class women)."),
|
| 75 |
+
gr.Textbox(label="Demographic", placeholder="Target demographic (e.g., 18-30, working women)."),
|
| 76 |
+
gr.Textbox(label="Video Duration (in seconds)", placeholder="Enter the total video duration (e.g., 30)."),
|
| 77 |
+
gr.Textbox(label="Number of Frames", placeholder="Enter the number of storyboard frames (e.g., 10)."),
|
| 78 |
+
gr.Dropdown(label="Emotional Appeal", choices=[
|
| 79 |
+
"Trust", "Excitement", "Happiness", "Inspiration", "Empowerment", "Elegance", "Confidence",
|
| 80 |
+
"Love", "Joy", "Ambition", "Passion", "Security", "Nostalgia", "Friendship", "Freedom"]),
|
| 81 |
+
gr.Textbox(label="Key Features", placeholder="List the product's key features, separated by commas."),
|
| 82 |
+
gr.Textbox(label="Call to Action", placeholder="Write a clear CTA, e.g., 'Buy Now', 'Visit Our Website'."),
|
| 83 |
+
gr.Dropdown(label="Primary Location", choices=[
|
| 84 |
+
"Urban", "Rural", "Office", "Shopping Mall", "House", "Party", "Outdoor Park",
|
| 85 |
+
"Beach", "Restaurant", "Gym", "City Street", "Countryside", "Airport", "Hotel", "Studio"]),
|
| 86 |
+
gr.Dropdown(label="Music Genre", choices=[
|
| 87 |
+
"Upbeat Electronic", "Soft Acoustic", "Cinematic", "Ambient", "Pop", "Jazz", "Classical",
|
| 88 |
+
"Rock", "Dance", "Chillwave", "Lo-Fi", "Hip-Hop", "Orchestral", "World Music", "Funk"]),
|
| 89 |
+
gr.Dropdown(label="Shot Types", choices=[
|
| 90 |
+
"Mix Shot", "Close-Up", "Wide Shot", "Mid Shot", "Tracking Shot", "Overhead Shot",
|
| 91 |
+
"High Angle", "Low Angle", "Point-of-View", "Dutch Angle", "Two-Shot", "Over-the-Shoulder",
|
| 92 |
+
"Establishing Shot", "Insert Shot", "Extreme Close-Up"]),
|
| 93 |
+
gr.Dropdown(label="AI Visual Style", choices=[
|
| 94 |
+
"Realistic", "Illustrative", "Cinematic", "Minimalistic", "Abstract", "Surreal", "Photorealistic",
|
| 95 |
+
"Vintage", "Futuristic", "Cartoonish", "Modern", "Retro", "High Contrast", "Black and White", "Dreamlike"]),
|
| 96 |
+
gr.Textbox(label="Additional Input", placeholder="Any additional notes or custom input for the creative process."),
|
| 97 |
+
],
|
| 98 |
+
outputs=gr.Textbox(label="Generated Detailed Screenplay"),
|
| 99 |
+
title="Creative Video Screenplay Generator",
|
| 100 |
+
description="Generate a highly detailed video screenplay with creative, visual, and emotional depth for your product."
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
iface.launch()
|