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