File size: 3,207 Bytes
90557f1
 
 
 
 
 
 
 
f0e7186
cb1984b
90557f1
 
 
f0e7186
90557f1
 
f0e7186
90557f1
 
f0e7186
90557f1
 
f0e7186
90557f1
f0e7186
 
90557f1
 
 
 
 
 
f0e7186
82768e6
f0e7186
 
 
 
 
 
 
 
 
 
 
90557f1
f0e7186
90557f1
 
 
 
 
 
 
 
 
 
 
 
 
f0e7186
90557f1
 
 
 
 
 
 
 
 
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
import streamlit as st
import openai
import os

# Set up OpenAI API key
openai.api_key = os.getenv("OPENAI_API_KEY")

def generate_video_script(title, formality_level, emotional_tone, engagement_level):
    # Construct the prompt with the provided details
    prompt = (
        f"[Use this video framework below]\n"
        f"First we need to have a strong hook.\n"
        f"A short intro that stops people from scrolling and holds their attention\n"
        f"Example: \"{title}\"\n"
        f"Now we add in “The Setup\"\n"
        f"* This is used to Setup the scene and provide context to the Viewer\n"
        f"* Example: \"I've been creating videos recently and I guess something finally clicked\"\n"
        f"ACT 2: \"The Conflict\"\n"
        f"* Introduce a point of conflict or problem that requires a solution\n"
        f"* Example: \"Some of you have been asking about scripting and storytelling and there's a lot to talk about, but I gotchu\"\n"
        f"ACT 3: \"The Resolution\"\n"
        f"* Addressing the conflict we introduced and resolving it\n"
        f"* Example: \"Here's how I tell my stories. All you need are these 3: ACT I, ACT II, and ACT III.\"\n"
        f"Call-To-Action\n"
        f"* Example: \"And if you wanna know how that looks like, then watch this video back and follow for more.\"\n"
        f"Follow these instructions above in creating a Viral Video script for me.\n"
        f"Topic: {title}\n"
        f"Tone: {emotional_tone}\n"
        f"Formality Level: {formality_level}\n"
        f"Engagement Level: {engagement_level}"
    )

    try:
        response = openai.Completion.create(
            engine="gpt-3.5-turbo",
            prompt=prompt,
            max_tokens=300,
            temperature=0.7,  # Adjust for creativity
            stop="\n"
        )
        script = response.choices[0].text.strip()
        return script
    except Exception as e:
        st.error(f"Failed to generate script: {str(e)}")
        return "Error in generating script."

# Streamlit UI setup
st.set_page_config(layout="wide")
st.markdown("<h1 style='text-align: center; color: black;'>Viral Video Script Generator</h1>", unsafe_allow_html=True)

# Create columns for input and output
col1, col2 = st.columns([3, 1])

with col1:
    st.markdown("<h2 style='text-align: center; color: black;'>Video Information</h2>", unsafe_allow_html=True)
    video_title = st.text_input("Title of Video", placeholder="Enter the title of your video")
    formality_level = st.selectbox("Formality Level", ["Casual", "Neutral", "Formal"])
    emotional_tone = st.selectbox("Emotional Tone", ["Positive", "Neutral", "Humorous"])
    engagement_level = st.selectbox("Engagement Level", ["Interactive", "Informative", "Persuasive"])

generate_button = col1.button('Generate Video Script')

if generate_button:
    if not video_title:
        st.error("Please enter the title of the video.")
    else:
        video_script = generate_video_script(video_title, formality_level, emotional_tone, engagement_level)
        with col2:
            st.markdown("<h2 style='text-align: center; color: black;'>Video Script</h2>", unsafe_allow_html=True)
            st.write(video_script)