File size: 8,249 Bytes
4b91275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d47ced6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b91275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
import os
import io
import streamlit as st
from groq import Groq

# Set up Groq client using the environment variable for API key.
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))

# Define the speaker options and their descriptions.
speaker_options = {
    "Liam": "A male voice",
    "Dorothy": "A female voice",
    "Josh": "A male voice",
    "Arnold": "A male voice",
    "Matilda": "A female voice",
    "Brian": "A narration voice",
    "Alice": "A news voice",
    "Bill": "A narration voice",
    "Callum": "A character voice",
    "Charlie": "A conversational voice",
    "Charlotte": "A character voice",
    "Chris": "A conversational voice",
    "Daniel": "A news voice",
    "Eric": "A voice",
    "George": "A narration voice",
    "Jessica": "A voice",
    "Laura": "A voice",
    "Lily": "A narration voice",
    "Sarah": "A news voice",
    "Will": "A voice"
}

# Build the Streamlit UI.
st.title("Conversation Script Generator Using Groq API")

# Layout two columns for speaker selection.
col1, col2 = st.columns(2)
with col1:
    left_speaker = st.selectbox(
        "Left Speaker",
        options=list(speaker_options.keys()),
        format_func=lambda x: f"{x}: {speaker_options[x]}"
    )
with col2:
    right_speaker = st.selectbox(
        "Right Speaker",
        options=list(speaker_options.keys()),
        format_func=lambda x: f"{x}: {speaker_options[x]}"
    )

# Text area for overall conversation theme.
theme = st.text_area("Overall Theme of the Conversation", height=100)

# Optional additional details.
additional_details = st.text_area("Additional Conversation Details (Optional)", height=100)

# When the user clicks the button, build the prompt and make the API call.
if st.button("Generate Conversation"):
    # Build the prompt message for Groq API.
    prompt = (
        f"""
        Objective:
Generate a highly engaging and comedic iMessage chat script formatted for video generation. The script should use distinct left and right voices, follow a structured format, and maintain a brain rot hook to keep the audience engaged. The story should be wacky, over-the-top, and meme-inspired while staying coherent.

1. FORMAT STRUCTURE (Regex-like Guide)
1.1 Contact Name (Title)
At the beginning of the script, define the contact name (the name that appears at the top of the iMessage screen).

php-template
Copy
Edit
<Contact Name>:<Contact Name>
Example:
ruby
Copy
Edit
Amir Uber Eats๐Ÿ”๐Ÿšš๐Ÿ—ฟ:Amir Uber Eats๐Ÿ”๐Ÿšš๐Ÿ—ฟ
1.2 Dialogue Format
Every dialogue line should follow this structure:

php-template
Copy
Edit
<Direction>: <SpeakerName> > <Dialogue> [<Reaction>]
<Direction> โ†’ Either Left: or Right:
Left: represents the left speaker (User).
Right: represents the right speaker (Other character).
<SpeakerName> โ†’ The voice actor name (which should remain consistent for left and right).
> โ†’ A separator between the speaker name and their dialogue.
<Dialogue> โ†’ The actual speech text, containing humor, slang, or randomness.
[<Reaction>] (Optional) โ†’ Emotional or sound-based cues (e.g., [shocked], [fart2], [get_out]).
Example:
vbnet
Copy
Edit
Left: Chinmay> Sir this is your Uber Eats order [shocked]
Right: Alex> BRO WHY IS THERE A RAT IN MY BURGER?!! [shocked] ๐Ÿ€๐Ÿ”
Left: Chinmay> Extra protein sir ๐Ÿ˜Ž
1.3 Bracketed Cues & Sound Effects
Use brackets [] to include sound effects, reactions, or video cues.

Common Examples:

[shocked] โ†’ Indicates the character is shocked.
[get_out] โ†’ Indicates the end of the conversation or dramatic exit.
[fart2] โ†’ Represents a comedic fart sound.
[suspense_music] โ†’ A cue for background music.
[explosion] โ†’ A big moment or reveal.
[slow_zoom] โ†’ A slow zoom-in effect for emphasis.
Example:
css
Copy
Edit
Right: Alex> WHY DID MY HOUSE JUST EXPLODE?!!! [explosion] ๐Ÿ’€๐Ÿ’€๐Ÿ’€
1.4 Image Placeholders
Images should be inserted where necessary using:

php-template
Copy
Edit
<Direction>: img:<DescriptiveImageName>
<DescriptiveImageName> โ†’ Describe the image clearly for easy attachment later.
Example:
vbnet
Copy
Edit
Left: img:burnt_food_delivery
Right: Alex> BRO WHY IS MY PIZZA LOOKING LIKE CHARCOAL?!! [shocked]
1.5 Special Sections (Cantina App / Roast Bot)
Incorporate Roast Bot mechanics where the character opens an app mid-conversation to ask for a roast.

Format:

vbnet
Copy
Edit
Cantina: Roast bot:Roast bot pfp == <Speaker> Let me open the cantina app to talk to Roast bot
Then, the roast bot provides a response.

Example:
vbnet
Copy
Edit
Cantina: Roast bot:Roast bot pfp == Alex> Let me open the cantina app to talk to Roast bot
Right: Alex> This guy just delivered my food and scammed me ๐Ÿ˜ก
Left: Antoni> Tell him this: "Sir, you pay less than a dollar tip and expect a five-star service?"
Right: Alex> YOU DID ME DIRTY BRO ๐Ÿ˜ญ๐Ÿ˜ญ
2. STORY GENERATION GUIDELINES
2.1 Catchy โ€œBrain Rotโ€ Hook
The first few lines must be highly engaging, over-the-top, and create curiosity.
Examples:

"BRO I JUST ORDERED UBER EATS AND THIS GUY SHOWED UP IN A SPACESHIP???" ๐Ÿš€๐Ÿ‘€
"WHY DID MY DAD JUST SAY HE WANTS TO PLAY GTA WITH ME???" ๐ŸŽฎ๐Ÿ’€
"SIR WHY IS MY LAWYER ALSO MY UBER DRIVER?!" ๐Ÿ‘จโ€โš–๏ธ๐Ÿš—๐Ÿ’จ
This hook should create an instant โ€œWTF?!โ€ reaction and force the reader to keep watching.

2.2 Story Progression (Random but Coherent)
The storyline must escalate in craziness but still have a logical flow.
Use sudden twists and reveals to keep the audience engaged.
End with a memorable punchline, twist, or dramatic exit.
Example Storyline Flow:
Crazy Hook: โ€œBRO WHY IS MY PIZZA DELIVERY GUY ALSO MY LAWYER???โ€ ๐Ÿ•๐Ÿ‘จโ€โš–๏ธ
Escalation: The lawyer admits he took the case without reading it.
Insane Event: The customer confesses to stealing a fighter jet.
Twist: Lawyer says, โ€œOh I do that every day, sir.โ€ ๐Ÿ˜Ž
Final Joke/Twist: The lawyer wins the case in 5 seconds and gets a $2 tip.
2.3 Humor & Slang
Use casual meme-inspired language (brain rot humor).
Include exaggerated reactions (e.g., "BROOO ๐Ÿ’€๐Ÿ’€๐Ÿ’€", "NO WAY", "HELP ME").
Use text formatting like uppercase for dramatic lines.
Example:
vbnet
Copy
Edit
Right: Alex> BRO WTF IS THIS BURGER?! [shocked]
Left: Chinmay> Sir, it's called a **mystery meat special** ๐Ÿ˜Ž
Right: Alex> MYSTERY??? FROM WHAT ANIMAL?!?!
Left: Chinmay> ๐Ÿ˜ถ
3. PARAMETERS & CUSTOMIZATION OPTIONS
When prompting the AI, specify the following:

Left and Right Voice Actors โ†’ Who will play each side (e.g., AI voice "John" for left, "Jake" for right).
Story Theme โ†’ Choose a base premise (e.g., "Uber Eats Disaster", "Courtroom Chaos", "Dad Discovers GTA").


Left Actor={left_speaker}
Right Actor={right_speaker}
Theme={theme}
        
        
        """
    )
    if additional_details.strip():
        prompt += f"Additional Details: {additional_details}\n"

    # Display the generated prompt for debugging.
    st.write("### Generated Prompt")
    st.code(prompt)

    # Prepare the message payload for the Groq API call.
    messages = [
        {
            "role": "user",
            "content": prompt,
        }
    ]
    
    # Model selection: adjust as needed.
    model = "llama-3.3-70b-versatile"

    try:
        # Make the chat completion call using Groq.
        chat_completion = client.chat.completions.create(
            messages=messages,
            model=model,
        )

        # Extract the generated conversation from the API response.
        result_text = chat_completion.choices[0].message.content

        if not result_text:
            st.error("The API call did not return any content.")
        else:
            st.success("Conversation generated successfully!")
            
            # Display the result inside a text area.
            st.write("### Generated Conversation Script")
            st.text_area("", result_text, height=300)
            
            # Create a downloadable TXT file.
            txt_bytes = result_text.encode("utf-8")
            txt_io = io.BytesIO(txt_bytes)
            st.download_button(
                label="Download Script as TXT",
                data=txt_io,
                file_name="conversation_script.txt",
                mime="text/plain"
            )

    except Exception as e:
        st.error(f"An error occurred while calling the API: {e}")