Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
import os
|
4 |
+
from utils import generate_script
|
5 |
+
|
6 |
+
# Load environment variables
|
7 |
+
load_dotenv()
|
8 |
+
|
9 |
+
# App title and header
|
10 |
+
st.title("YouTube Scriptwriting Tool")
|
11 |
+
st.header("Generate a video script by specifying a topic, length, and creativity level.")
|
12 |
+
|
13 |
+
# Sidebar for API configuration
|
14 |
+
st.sidebar.title("API Configuration")
|
15 |
+
google_api_key = st.sidebar.text_input("Enter your Gemini API key:", type="password", key="api_key")
|
16 |
+
|
17 |
+
# Main input fields
|
18 |
+
prompt = st.text_input("Provide the topic of the video:")
|
19 |
+
video_length = st.number_input("Specify video length (in minutes):", min_value=1.0, step=0.5)
|
20 |
+
creativity = st.slider("Set creativity level:", min_value=0.0, max_value=1.0, value=0.5)
|
21 |
+
|
22 |
+
# Button to generate script
|
23 |
+
if st.button("Generate Script"):
|
24 |
+
if not google_api_key:
|
25 |
+
st.error("Please provide a valid Gemini API key.")
|
26 |
+
elif not prompt:
|
27 |
+
st.error("Topic cannot be empty.")
|
28 |
+
else:
|
29 |
+
# Call the script generation utility
|
30 |
+
try:
|
31 |
+
title, script, search_data = generate_script(prompt, video_length, creativity, google_api_key)
|
32 |
+
st.success("Script generated successfully!")
|
33 |
+
st.subheader(f"Title: {title}")
|
34 |
+
st.write(f"Script:\n\n{script}")
|
35 |
+
with st.expander("Show search data used for the script"):
|
36 |
+
st.write(search_data)
|
37 |
+
except Exception as e:
|
38 |
+
st.error(f"An error occurred: {e}")
|