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