Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,9 @@ load_dotenv()
|
|
9 |
st.title("YouTube Scriptwriting Tool")
|
10 |
st.header("Generate a video script by specifying a topic, length, and creativity level.")
|
11 |
|
12 |
-
# Sidebar to capture API key (use the
|
13 |
st.sidebar.title("API Configuration")
|
14 |
-
st.sidebar.text_input("Enter your
|
15 |
|
16 |
# Main input fields for the video script
|
17 |
prompt = st.text_input("Provide the topic of the video:")
|
@@ -23,14 +23,17 @@ generate_script_button = st.button("Generate Script")
|
|
23 |
|
24 |
# When the button is clicked, the script will be generated
|
25 |
if generate_script_button:
|
26 |
-
|
27 |
-
if not
|
28 |
-
st.error("Please provide a valid
|
29 |
else:
|
30 |
# Generate the script using the utility function
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
st.
|
|
|
|
|
|
|
|
9 |
st.title("YouTube Scriptwriting Tool")
|
10 |
st.header("Generate a video script by specifying a topic, length, and creativity level.")
|
11 |
|
12 |
+
# Sidebar to capture API key (use the SerpAPI Key here)
|
13 |
st.sidebar.title("API Configuration")
|
14 |
+
st.sidebar.text_input("Enter your SerpAPI key:", type="password", key="serpapi_key")
|
15 |
|
16 |
# Main input fields for the video script
|
17 |
prompt = st.text_input("Provide the topic of the video:")
|
|
|
23 |
|
24 |
# When the button is clicked, the script will be generated
|
25 |
if generate_script_button:
|
26 |
+
serpapi_key = st.session_state.serpapi_key
|
27 |
+
if not serpapi_key:
|
28 |
+
st.error("Please provide a valid SerpAPI key.")
|
29 |
else:
|
30 |
# Generate the script using the utility function
|
31 |
+
try:
|
32 |
+
title, script, search_data = generate_script(prompt, video_length, creativity, serpapi_key)
|
33 |
+
st.success("Script generated successfully!")
|
34 |
+
st.subheader(f"Title: {title}")
|
35 |
+
st.write(f"Script:\n\n{script}")
|
36 |
+
with st.expander("Show search data used for the script"):
|
37 |
+
st.write(search_data)
|
38 |
+
except Exception as e:
|
39 |
+
st.error(f"An error occurred: {e}")
|