Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- README.md +70 -14
- app.py +61 -0
- prompts.py +53 -0
- requirements.txt +3 -0
README.md
CHANGED
|
@@ -1,14 +1,70 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π iBoothMe Case Study Generator
|
| 2 |
+
|
| 3 |
+
This is a Gradio-based AI tool that generates energetic, structured marketing case studies from informal brand activation event descriptions. It supports both **text input** and **audio input**. The audio is transcribed using **OpenAI Whisper**, and the case study is generated using **GPT-4o**.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## π Features
|
| 8 |
+
|
| 9 |
+
- π Paste or write an informal event description
|
| 10 |
+
- ποΈ Upload or record audio to transcribe via OpenAI Whisper
|
| 11 |
+
- π Generates structured case studies in the format: **Challenge**, **Solution**, and optional **Results**
|
| 12 |
+
- β¨ Uses a pre-defined prompt system to match real-world case study tone and format
|
| 13 |
+
- ποΈ Clean, tabbed Gradio UI with audio and text support
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## π§± Tech Stack
|
| 18 |
+
|
| 19 |
+
- Python π
|
| 20 |
+
- Gradio ποΈ
|
| 21 |
+
- OpenAI GPT-4o & Whisper π§
|
| 22 |
+
- dotenv for API key management π
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## π§© File Structure
|
| 27 |
+
|
| 28 |
+
```
|
| 29 |
+
CaseStudy_Generator/
|
| 30 |
+
βββ main.py
|
| 31 |
+
βββ prompts.py
|
| 32 |
+
βββ .env
|
| 33 |
+
βββ requirements.txt
|
| 34 |
+
βββ README.md
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
## π₯ Installation & Setup
|
| 40 |
+
|
| 41 |
+
### 1. Clone the Repository
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
git clone https://github.com/SummeyaTahir/Clean_CaseStudy_Generator.git
|
| 45 |
+
cd Clean_CaseStudy_Generator
|
| 46 |
+
```
|
| 47 |
+
### 2. (Optional) Create a Virtual Environment
|
| 48 |
+
```bash
|
| 49 |
+
python -m venv venv
|
| 50 |
+
venv\Scripts\activate # On Windows
|
| 51 |
+
# source venv/bin/activate # On Mac/Linux
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
### 3. Install the Requirements
|
| 55 |
+
```bash
|
| 56 |
+
pip install -r requirements.txt
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### 3. Create .env File
|
| 60 |
+
Create a .env file in the root directory and paste this into it:
|
| 61 |
+
```bash
|
| 62 |
+
|
| 63 |
+
OPENAI_API_KEY=your-openai-api-key-here
|
| 64 |
+
```
|
| 65 |
+
### 4. βΆοΈ Run the App
|
| 66 |
+
```bash
|
| 67 |
+
python main.py
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
|
app.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import openai
|
| 5 |
+
from prompts import SYSTEM_PROMPT
|
| 6 |
+
|
| 7 |
+
# π₯ Load environment variables
|
| 8 |
+
load_dotenv()
|
| 9 |
+
|
| 10 |
+
client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 11 |
+
|
| 12 |
+
# π Transcribe audio input using OpenAI Whisper API
|
| 13 |
+
def transcribe_audio(audio_file):
|
| 14 |
+
with open(audio_file, "rb") as f:
|
| 15 |
+
transcript = client.audio.transcriptions.create(
|
| 16 |
+
model="whisper-1",
|
| 17 |
+
file=f
|
| 18 |
+
)
|
| 19 |
+
return transcript.text
|
| 20 |
+
|
| 21 |
+
# π¬ Call OpenAI chat with the transcribed or text input
|
| 22 |
+
def call_openai(event_details):
|
| 23 |
+
prompt = SYSTEM_PROMPT.format(event_details)
|
| 24 |
+
response = client.chat.completions.create(
|
| 25 |
+
model="gpt-4o",
|
| 26 |
+
messages=[{"role": "user", "content": prompt}],
|
| 27 |
+
temperature=0.5,
|
| 28 |
+
max_tokens=1024,
|
| 29 |
+
)
|
| 30 |
+
return response.choices[0].message.content
|
| 31 |
+
|
| 32 |
+
# π New function to handle audio input and route to existing pipeline
|
| 33 |
+
def case_study_from_audio(audio):
|
| 34 |
+
text = transcribe_audio(audio)
|
| 35 |
+
return case_study_generator(text)
|
| 36 |
+
|
| 37 |
+
# ποΈ Original function β unchanged
|
| 38 |
+
def case_study_generator(event_details):
|
| 39 |
+
gpt_response = call_openai(event_details)
|
| 40 |
+
return gpt_response
|
| 41 |
+
|
| 42 |
+
# π Gradio interface with two modes: Text or Audio
|
| 43 |
+
with gr.Blocks() as demo:
|
| 44 |
+
gr.Markdown("## π iBoothMe Case Study Generator\nWrite a description or record audio.")
|
| 45 |
+
with gr.Tab("Text Input"):
|
| 46 |
+
text_input = gr.Textbox(
|
| 47 |
+
label="Event Description",
|
| 48 |
+
lines=10,
|
| 49 |
+
placeholder="Paste informal event description here...",
|
| 50 |
+
)
|
| 51 |
+
text_button = gr.Button("Generate from Text")
|
| 52 |
+
text_output = gr.Textbox(label="Generated Case Study", lines=15)
|
| 53 |
+
text_button.click(fn=case_study_generator, inputs=text_input, outputs=text_output)
|
| 54 |
+
|
| 55 |
+
with gr.Tab("Audio Input"):
|
| 56 |
+
audio_input = gr.Audio(type="filepath", label="Upload or Record your event description")
|
| 57 |
+
audio_button = gr.Button("Generate from Audio")
|
| 58 |
+
audio_output = gr.Textbox(label="Generated Case Study", lines=15)
|
| 59 |
+
audio_button.click(fn=case_study_from_audio, inputs=audio_input, outputs=audio_output)
|
| 60 |
+
|
| 61 |
+
demo.launch()
|
prompts.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
SYSTEM_PROMPT = """You are a creative writer on the iBoothMe team.
|
| 2 |
+
|
| 3 |
+
Generate a short, well-structured **case study** from informal brand activation event details. Follow this format exactly:
|
| 4 |
+
|
| 5 |
+
1. Start with **"Challenge:"** β explain the brand's goal/problem simply.
|
| 6 |
+
2. Then write **"Solution:"** β show how iBoothMe solved it using a product or tech with flair.
|
| 7 |
+
|
| 8 |
+
3. Include **"Results:"** only if the event detail mentions clear metrics or success indicators (like number of participants, engagement stats, product pickups, QR scans, impressions, conversions, etc).
|
| 9 |
+
**If there are no measurable results or clear impact in the event detail, leave the "Results:" section out completely.**
|
| 10 |
+
### Instructions for **Results** section:
|
| 11 |
+
- Include no more than 3 bullet points
|
| 12 |
+
- Keep bullets short, punchy, and brand-activation styled β iBoothMe tone
|
| 13 |
+
- Avoid repeating similar numbers. Choose only the most impactful 2-3 results.
|
| 14 |
+
**Example:**
|
| 15 |
+
- 983 unique leads collected in 6 hours
|
| 16 |
+
- 1,200 Carmex samples distributed
|
| 17 |
+
- 87% booth engagement rate
|
| 18 |
+
|
| 19 |
+
### Tone and Structure Related Instructions:
|
| 20 |
+
- Use a confident, energetic tone β keep it short and vivid (2-3 sentences per section max).
|
| 21 |
+
- Do NOT over-explain the products. Just blend them naturally into the solution.
|
| 22 |
+
- Match the exact **style and tone** of these examples below (especially structure and length):
|
| 23 |
+
|
| 24 |
+
### Examples:
|
| 25 |
+
#### Case Study 1
|
| 26 |
+
Challenge:
|
| 27 |
+
For the IIFA 2023 Bollywood awards night, the challenge was to provide a high-end, interactive photo experience for mega film stars like Salman Khan and Hrithik Roshan, while ensuring fast, seamless operation amidst the event's glitz and glamour.
|
| 28 |
+
Solution:
|
| 29 |
+
We deployed our 180 Photobooth, equipped with 11 DSLR cameras to capture picture-perfect photos and GIFs. The booth allowed celebrities to strike glamorous poses, producing high-quality, shareable content. Its rapid operation ensured all stars could enjoy the experience without disrupting the flow of the event. The result was a star-studded activation that brought the essence of Bollywood to life, creating unforgettable memories for all attendees.
|
| 30 |
+
|
| 31 |
+
#### Case Study 2
|
| 32 |
+
Challenge:
|
| 33 |
+
Shein's Challenge was letting their prospects visit their stand and remain in it to be educated about their new product line.
|
| 34 |
+
Solution:
|
| 35 |
+
We created a phone booth that rings unexpectedly, delivering a recorded voice message with a four-digit code, enabling participants to try unlocking the Giftbox. Inside the Giftbox lay Shein's product, and anticipation built as prospects eagerly awaited the ringing phone to try to get the prize.
|
| 36 |
+
|
| 37 |
+
#### Case Study 3
|
| 38 |
+
Challenge:
|
| 39 |
+
Sephora's Challenge was to grab students' attention around their products in a university and collect their database while increasing their sales.
|
| 40 |
+
Solution:
|
| 41 |
+
The Claw captured the entire focus of Sephora's prospects on their product, attempting to seize them. The essence of this strategy lies in fostering attention and stimulating desire for their product.
|
| 42 |
+
|
| 43 |
+
#### Case Study 4
|
| 44 |
+
Challenge:
|
| 45 |
+
Burger King introduced their new chicken burger intending to excite millennials in food courts. Their second goal was to spark curiosity among potential customers at the activation, spreading the word about their new burger throughout the town.
|
| 46 |
+
Solution:
|
| 47 |
+
We have developed a voice command game where the character is a Chicken, and to let the chicken jump to avoid traps, prospects had to imitate the sound of the chicken. It was exceptionally entertaining, and everyone was gathering around Burger Kingβs activation.
|
| 48 |
+
|
| 49 |
+
Now write a case study using the following event detail:
|
| 50 |
+
|
| 51 |
+
Event Detail:
|
| 52 |
+
{}
|
| 53 |
+
"""
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=4.14.0
|
| 2 |
+
openai>=1.0.0
|
| 3 |
+
python-dotenv
|