Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,46 +1,53 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import openai
|
| 3 |
|
| 4 |
-
# Access the OpenAI API key from
|
| 5 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 6 |
|
| 7 |
-
st.title("
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
investment_amount = st.number_input("Amount Available for Investment", min_value=1000, max_value=500000, step=100) # Removed format argument
|
| 18 |
-
risk_tolerance = st.selectbox("Risk Tolerance", ["Low", "Medium", "High"])
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
)
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
# Call the OpenAI API for text generation
|
| 29 |
try:
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
)
|
| 37 |
-
|
| 38 |
except Exception as e:
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
# Display the
|
| 42 |
-
st.markdown("###
|
| 43 |
-
st.write(
|
| 44 |
|
| 45 |
# Disclaimer
|
| 46 |
-
st.write("Disclaimer: This tool provides
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import openai
|
| 3 |
|
| 4 |
+
# Access the OpenAI API key from Hugging Face Spaces secrets or your environment variables
|
| 5 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 6 |
|
| 7 |
+
st.title("Video Script Generator")
|
| 8 |
|
| 9 |
+
# Define video styles and their descriptions
|
| 10 |
+
video_styles = {
|
| 11 |
+
"Explainer": "Explainer videos break down complex concepts into simple, engaging visuals and narratives.",
|
| 12 |
+
"Testimonial": "Testimonial videos feature satisfied customers sharing their positive experiences.",
|
| 13 |
+
"Product Demo": "Product demos showcase the features and benefits of a product in action.",
|
| 14 |
+
"How-To": "How-to videos provide step-by-step instructions on performing a task or using a product.",
|
| 15 |
+
"Brand Story": "Brand story videos share the company's mission, vision, and values, connecting emotionally with the audience."
|
| 16 |
+
}
|
| 17 |
|
| 18 |
+
# User selects the video style
|
| 19 |
+
video_style = st.selectbox("Choose the style of video you want to create:", options=list(video_styles.keys()))
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
# Display the description of the selected video style
|
| 22 |
+
st.write(f"**Description:** {video_styles[video_style]}")
|
| 23 |
+
|
| 24 |
+
# Additional inputs
|
| 25 |
+
business_name = st.text_input("Business Name", "Your Business Name")
|
| 26 |
+
target_audience = st.text_area("Target Audience", "Describe your target audience.")
|
|
|
|
| 27 |
|
| 28 |
+
# Button to generate video script
|
| 29 |
+
if st.button('Generate Video Script'):
|
| 30 |
+
# Construct the prompt for the AI
|
| 31 |
+
prompt_text = f"Create a script for a {video_style.lower()} video for '{business_name}' targeting '{target_audience}'. {video_styles[video_style]}"
|
| 32 |
+
|
| 33 |
# Call the OpenAI API for text generation
|
| 34 |
try:
|
| 35 |
+
response = openai.Completion.create(
|
| 36 |
+
engine="text-davinci-003",
|
| 37 |
+
prompt=prompt_text,
|
| 38 |
+
max_tokens=500,
|
| 39 |
+
temperature=0.7,
|
| 40 |
+
top_p=1,
|
| 41 |
+
frequency_penalty=0,
|
| 42 |
+
presence_penalty=0
|
| 43 |
)
|
| 44 |
+
script = response.choices[0].text.strip()
|
| 45 |
except Exception as e:
|
| 46 |
+
script = f"Error in generating script: {e}"
|
| 47 |
+
|
| 48 |
+
# Display the generated script
|
| 49 |
+
st.markdown("### Generated Video Script")
|
| 50 |
+
st.write(script)
|
| 51 |
|
| 52 |
# Disclaimer
|
| 53 |
+
st.write("Disclaimer: This tool provides AI-generated suggestions. Please review and customize the script to fit your specific business needs.")
|