|
import streamlit as st |
|
import openai |
|
import os |
|
|
|
|
|
openai.api_key = os.getenv("OPENAI_API_KEY") |
|
|
|
def generate_video_script(title, formality_level, emotional_tone, engagement_level): |
|
|
|
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, |
|
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." |
|
|
|
|
|
st.set_page_config(layout="wide") |
|
st.markdown("<h1 style='text-align: center; color: black;'>Viral Video Script Generator</h1>", unsafe_allow_html=True) |
|
|
|
|
|
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) |
|
|