Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from utils import generate_script
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
|
5 |
+
load_dotenv()
|
6 |
+
|
7 |
+
# Applying Styling
|
8 |
+
st.markdown("""
|
9 |
+
<style>
|
10 |
+
div.stButton > button:first-child {
|
11 |
+
background-color: #0099ff;
|
12 |
+
color:#ffffff;
|
13 |
+
}
|
14 |
+
div.stButton > button:hover {
|
15 |
+
background-color: #00ff00;
|
16 |
+
color:#FFFFFF;
|
17 |
+
}
|
18 |
+
</style>""", unsafe_allow_html=True)
|
19 |
+
|
20 |
+
|
21 |
+
# Creating Session State Variable
|
22 |
+
if 'API_Key' not in st.session_state:
|
23 |
+
st.session_state['API_Key'] =''
|
24 |
+
|
25 |
+
|
26 |
+
st.title('β€οΈ YouTube Script Writing Tool')
|
27 |
+
|
28 |
+
# Sidebar to capture the OpenAi API key
|
29 |
+
st.sidebar.title("πποΈ")
|
30 |
+
st.session_state['API_Key']= st.sidebar.text_input("What's your API key?",type="password")
|
31 |
+
st.sidebar.image('./Youtube.jpg',width=300, use_column_width=True)
|
32 |
+
|
33 |
+
|
34 |
+
# Captures User Inputs
|
35 |
+
prompt = st.text_input('Please provide the topic of the video',key="prompt") # The box for the text prompt
|
36 |
+
video_length = st.text_input('Expected Video Length π (in minutes)',key="video_length") # The box for the text prompt
|
37 |
+
creativity = st.slider('Words limit β¨ - (0 LOW || 1 HIGH)', 0.0, 1.0, 0.2,step=0.1)
|
38 |
+
|
39 |
+
submit = st.button("Generate Script")
|
40 |
+
|
41 |
+
|
42 |
+
if submit:
|
43 |
+
|
44 |
+
if st.session_state['API_Key']:
|
45 |
+
search_result, title, script = generate_script(prompt,video_length,creativity,st.session_state['API_Key'])
|
46 |
+
#Let's generate the script
|
47 |
+
st.success('Hope you like this script β€οΈ')
|
48 |
+
|
49 |
+
#Display Title
|
50 |
+
st.subheader("Title:π₯")
|
51 |
+
st.write(title)
|
52 |
+
|
53 |
+
#Display Video Script
|
54 |
+
st.subheader("Your Video Script:π")
|
55 |
+
st.write(script)
|
56 |
+
|
57 |
+
#Display Search Engine Result
|
58 |
+
st.subheader("Check Out - DuckDuckGo Search:π")
|
59 |
+
with st.expander('Show me π'):
|
60 |
+
st.info(search_result)
|
61 |
+
else:
|
62 |
+
st.error("Ooopssss!!! Please provide API key.....")
|