dlennon commited on
Commit
f0e7186
·
verified ·
1 Parent(s): cb1984b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -27
app.py CHANGED
@@ -6,64 +6,59 @@ import os
6
  openai.api_key = os.getenv("OPENAI_API_KEY")
7
 
8
  def generate_video_script(title, formality_level, emotional_tone, engagement_level):
 
9
  prompt = (
10
  f"[Use this video framework below]\n"
11
  f"First we need to have a strong hook.\n"
12
  f"A short intro that stops people from scrolling and holds their attention\n"
13
- f"Example. \"{title}\"\n"
14
  f"Now we add in “The Setup\"\n"
15
  f"* This is used to Setup the scene and provide context to the Viewer\n"
16
- f"* ex. \"I've been creating videos recently and I guess something finally clicked\"\n"
17
- 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"
18
  f"ACT 2: \"The Conflict\"\n"
19
  f"* Introduce a point of conflict or problem that requires a solution\n"
20
- f"* ex. \"Some of you have been asking about scripting and storytelling and there's a lot to talk about, but I gotchu\"\n"
21
- 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"
22
- f"* Which opens the question of how we're going to tackle the topic in a limited amount of time\n"
23
  f"ACT 3: \"The Resolution\"\n"
24
  f"* Addressing the conflict we introduced and resolving it\n"
25
- f"* ex. \"Here's how I tell my stories. All you need are these 3: ACT I, ACT II, and ACT III.\"\n"
26
- f"* She proceeds to explain how we structure and tell our stories, which answers and resolves the initial conflict\n"
27
- f"A call to action or loop.\n"
28
  f"Call-To-Action\n"
29
- f"* After giving valuable information to your viewer, you have to be able to lead them somewhere or encourage them to engage\n"
30
- f"* ex. \"And if you wanna know how that looks like, then watch this video back and follow for more.\"\n"
31
- 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!"
32
- f"Follow these instructions above in creating a Viral Video script for me."
33
  f"Topic: {title}\n"
34
  f"Tone: {emotional_tone}\n"
35
  f"Formality Level: {formality_level}\n"
36
  f"Engagement Level: {engagement_level}"
37
  )
38
 
39
- response = openai.ChatCompletion.create(
40
- engine="gpt-3.5-turbo",
41
- prompt=prompt,
42
- max_tokens=300,
43
- stop="\n"
44
- )
45
-
46
- script = response.choices[0].text.strip()
47
- return script
 
 
 
 
48
 
49
- # Streamlit UI for collecting inputs
50
  st.set_page_config(layout="wide")
51
  st.markdown("<h1 style='text-align: center; color: black;'>Viral Video Script Generator</h1>", unsafe_allow_html=True)
52
 
53
  # Create columns for input and output
54
  col1, col2 = st.columns([3, 1])
55
 
56
- # User input sections
57
  with col1:
58
  st.markdown("<h2 style='text-align: center; color: black;'>Video Information</h2>", unsafe_allow_html=True)
59
  video_title = st.text_input("Title of Video", placeholder="Enter the title of your video")
60
- intended_audience = st.text_input("Intended Audience", placeholder="Who is your intended audience?")
61
  formality_level = st.selectbox("Formality Level", ["Casual", "Neutral", "Formal"])
62
  emotional_tone = st.selectbox("Emotional Tone", ["Positive", "Neutral", "Humorous"])
63
  engagement_level = st.selectbox("Engagement Level", ["Interactive", "Informative", "Persuasive"])
64
 
65
- # If the button is pressed, generate video script and display in the second column (right)
66
- generate_button = col1.button('Generate Video Script') # Place the button in the first column
67
 
68
  if generate_button:
69
  if not video_title:
 
6
  openai.api_key = os.getenv("OPENAI_API_KEY")
7
 
8
  def generate_video_script(title, formality_level, emotional_tone, engagement_level):
9
+ # Construct the prompt with the provided details
10
  prompt = (
11
  f"[Use this video framework below]\n"
12
  f"First we need to have a strong hook.\n"
13
  f"A short intro that stops people from scrolling and holds their attention\n"
14
+ f"Example: \"{title}\"\n"
15
  f"Now we add in “The Setup\"\n"
16
  f"* This is used to Setup the scene and provide context to the Viewer\n"
17
+ f"* Example: \"I've been creating videos recently and I guess something finally clicked\"\n"
 
18
  f"ACT 2: \"The Conflict\"\n"
19
  f"* Introduce a point of conflict or problem that requires a solution\n"
20
+ f"* Example: \"Some of you have been asking about scripting and storytelling and there's a lot to talk about, but I gotchu\"\n"
 
 
21
  f"ACT 3: \"The Resolution\"\n"
22
  f"* Addressing the conflict we introduced and resolving it\n"
23
+ f"* Example: \"Here's how I tell my stories. All you need are these 3: ACT I, ACT II, and ACT III.\"\n"
 
 
24
  f"Call-To-Action\n"
25
+ f"* Example: \"And if you wanna know how that looks like, then watch this video back and follow for more.\"\n"
26
+ f"Follow these instructions above in creating a Viral Video script for me.\n"
 
 
27
  f"Topic: {title}\n"
28
  f"Tone: {emotional_tone}\n"
29
  f"Formality Level: {formality_level}\n"
30
  f"Engagement Level: {engagement_level}"
31
  )
32
 
33
+ try:
34
+ response = openai.ChatCompletion.create(
35
+ engine="gpt-3.5-turbo",
36
+ prompt=prompt,
37
+ max_tokens=300,
38
+ temperature=0.7, # Adjust for creativity
39
+ stop="\n"
40
+ )
41
+ script = response.choices[0].text.strip()
42
+ return script
43
+ except Exception as e:
44
+ st.error(f"Failed to generate script: {str(e)}")
45
+ return "Error in generating script."
46
 
47
+ # Streamlit UI setup
48
  st.set_page_config(layout="wide")
49
  st.markdown("<h1 style='text-align: center; color: black;'>Viral Video Script Generator</h1>", unsafe_allow_html=True)
50
 
51
  # Create columns for input and output
52
  col1, col2 = st.columns([3, 1])
53
 
 
54
  with col1:
55
  st.markdown("<h2 style='text-align: center; color: black;'>Video Information</h2>", unsafe_allow_html=True)
56
  video_title = st.text_input("Title of Video", placeholder="Enter the title of your video")
 
57
  formality_level = st.selectbox("Formality Level", ["Casual", "Neutral", "Formal"])
58
  emotional_tone = st.selectbox("Emotional Tone", ["Positive", "Neutral", "Humorous"])
59
  engagement_level = st.selectbox("Engagement Level", ["Interactive", "Informative", "Persuasive"])
60
 
61
+ generate_button = col1.button('Generate Video Script')
 
62
 
63
  if generate_button:
64
  if not video_title: