Spaces:
Runtime error
Runtime error
File size: 4,101 Bytes
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 72 73 74 75 76 |
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):
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"* ex. \"I've been creating videos recently and I guess something finally clicked\"\n"
f"* This lets the viewer know that she’s been uploading more videos recently, and that could have led to an increase in views and followers.\n"
f"ACT 2: \"The Conflict\"\n"
f"* Introduce a point of conflict or problem that requires a solution\n"
f"* ex. \"Some of you have been asking about scripting and storytelling and there's a lot to talk about, but I gotchu\"\n"
f"* Setting up the foundation to lead to the topic of the video and posing the concern that 'there's a lot to talk about'\n"
f"* Which opens the question of how we're going to tackle the topic in a limited amount of time\n"
f"ACT 3: \"The Resolution\"\n"
f"* Addressing the conflict we introduced and resolving it\n"
f"* ex. \"Here's how I tell my stories. All you need are these 3: ACT I, ACT II, and ACT III.\"\n"
f"* She proceeds to explain how we structure and tell our stories, which answers and resolves the initial conflict\n"
f"A call to action or loop.\n"
f"Call-To-Action\n"
f"* After giving valuable information to your viewer, you have to be able to lead them somewhere or encourage them to engage\n"
f"* ex. \"And if you wanna know how that looks like, then watch this video back and follow for more.\"\n"
f"* This encourages the audience to rewatch the video to see the video is an actual example of what they just learned and it encourages them to follow and share the content if they found it valuable!"
f"Follow these instructions above in creating a Viral Video script for me."
f"Topic: {title}\n"
f"Tone: {emotional_tone}\n"
f"Formality Level: {formality_level}\n"
f"Engagement Level: {engagement_level}"
)
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
temperature=0.5,
max_tokens=1000
)
script = response.choices[0].text.strip()
return script
# Streamlit UI for collecting inputs
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])
# User input sections
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")
intended_audience = st.text_input("Intended Audience", placeholder="Who is your intended audience?")
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"])
# If the button is pressed, generate video script and display in the second column (right)
generate_button = col1.button('Generate Video Script') # Place the button in the first column
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)
|