nniehaus commited on
Commit
84e2e78
·
verified ·
1 Parent(s): 267080d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -31,6 +31,10 @@ def clean_script(script):
31
  cleaned_script = re.sub(r"([a-zA-Z])(\d+)", r"\1 \2", cleaned_script)
32
  return cleaned_script
33
 
 
 
 
 
34
  # Streamlit UI for input
35
  business_description = st.text_area(
36
  "Describe your business or video topic/idea:",
@@ -118,15 +122,17 @@ if generate_button:
118
  script = call_openai_api(prompt)
119
  if script:
120
  script = clean_script(script) # Clean the output
121
- st.markdown("### Generated Video Script")
122
- st.write(script)
 
 
 
 
123
 
124
- # Add a download button
125
- st.download_button(
126
- label="📥 Download Script as Text File",
127
- data=script,
128
- file_name='video_script.txt',
129
- mime='text/plain'
130
- )
131
- else:
132
- st.write("An error occurred while generating the script. Please try again.")
 
31
  cleaned_script = re.sub(r"([a-zA-Z])(\d+)", r"\1 \2", cleaned_script)
32
  return cleaned_script
33
 
34
+ # Initialize session state for script to avoid disappearing after download
35
+ if 'script' not in st.session_state:
36
+ st.session_state.script = ""
37
+
38
  # Streamlit UI for input
39
  business_description = st.text_area(
40
  "Describe your business or video topic/idea:",
 
122
  script = call_openai_api(prompt)
123
  if script:
124
  script = clean_script(script) # Clean the output
125
+ st.session_state.script = script # Store the generated script in session state
126
+
127
+ # Display the script if it exists
128
+ if st.session_state.script:
129
+ st.markdown("### Generated Video Script")
130
+ st.write(st.session_state.script)
131
 
132
+ # Add a download button
133
+ st.download_button(
134
+ label="📥 Download Script as Text File",
135
+ data=st.session_state.script,
136
+ file_name='video_script.txt',
137
+ mime='text/plain'
138
+ )