Spaces:
Runtime error
Runtime error
Commit
·
b771526
1
Parent(s):
c0b97e3
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,70 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
</style>
|
| 11 |
-
"""
|
| 12 |
-
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
#
|
| 28 |
-
if
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
+
st.set_page_config(
|
| 4 |
+
page_title="DiffSVC Render",
|
| 5 |
+
page_icon="🧊",
|
| 6 |
+
initial_sidebar_state="expanded",
|
| 7 |
+
)
|
| 8 |
+
############
|
| 9 |
+
st.title('DIFF-SVC Render')
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
###CKPT LOADER
|
| 12 |
+
ckpt = st.file_uploader("Choose your CKPT", type= 'ckpt')
|
| 13 |
+
# Check if user uploaded a CKPT file
|
| 14 |
+
if ckpt is not None:
|
| 15 |
+
#TEMP FUNCTION
|
| 16 |
+
with tempfile.NamedTemporaryFile(mode="wb", suffix='.ckpt', delete=False) as temp:
|
| 17 |
+
# Get the file contents as bytes
|
| 18 |
+
bytes_data = ckpt.getvalue()
|
| 19 |
+
# Write the bytes to the temporary file
|
| 20 |
+
temp.write(bytes_data)
|
| 21 |
+
ckpt_temp_file = temp.name
|
| 22 |
+
# Print the temporary file name
|
| 23 |
+
print(temp.name)
|
| 24 |
+
# Display the file path
|
| 25 |
+
if "ckpt_temp_file" in locals():
|
| 26 |
+
st.success("File saved to: {}".format(ckpt_temp_file))
|
| 27 |
+
# File uploader
|
| 28 |
+
config = st.file_uploader("Choose your config", type= 'yaml')
|
| 29 |
+
# Check if user uploaded a config file
|
| 30 |
+
if config is not None:
|
| 31 |
+
#TEMP FUNCTION
|
| 32 |
+
with tempfile.NamedTemporaryFile(mode="wb", suffix='.yaml', delete=False) as temp:
|
| 33 |
+
# Get the file contents as bytes
|
| 34 |
+
bytes_data = config.getvalue()
|
| 35 |
+
# Write the bytes to the temporary file
|
| 36 |
+
temp.write(bytes_data)
|
| 37 |
+
config_temp_file = temp.name
|
| 38 |
+
# Print the temporary file name
|
| 39 |
+
print(temp.name)
|
| 40 |
+
# Display the file path
|
| 41 |
+
if "config_temp_file" in locals():
|
| 42 |
+
st.success("File saved to: {}".format(config_temp_file))
|
| 43 |
+
audio = st.file_uploader("Choose your audio", type=["wav"])
|
| 44 |
+
# Check if user uploaded an audio file
|
| 45 |
+
if audio is not None:
|
| 46 |
+
#EMP FUNCTION
|
| 47 |
+
with tempfile.NamedTemporaryFile(mode="wb", suffix='.wav', delete=False) as temp:
|
| 48 |
+
# Get the file contents as bytes
|
| 49 |
+
bytes_data = audio.getvalue()
|
| 50 |
+
# Write the bytes to the temporary file
|
| 51 |
+
temp.write(bytes_data)
|
| 52 |
+
audio_temp_file = temp.name
|
| 53 |
+
# Print the temporary file name
|
| 54 |
+
print(temp.name)
|
| 55 |
+
# Display the file path
|
| 56 |
+
if "audio_temp_file" in locals():
|
| 57 |
+
st.success("File saved to: {}".format(audio_temp_file))
|
| 58 |
+
# Add a text input for the title with a default value of 0
|
| 59 |
+
title = st.text_input("Key", value="0")
|
| 60 |
+
title2 = st.text_input("Speedup", value="20")
|
| 61 |
+
if password = st.text_input("Enter password")
|
| 62 |
+
correct_password = os.environ.get("gatepassword")
|
| 63 |
+
# Add a button to start the rendering process
|
| 64 |
+
# Add a button to start the rendering process
|
| 65 |
+
if st.button("Render audio"):
|
| 66 |
+
if password == correct_password:
|
| 67 |
+
render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title, title2)
|
| 68 |
+
|
| 69 |
+
else:
|
| 70 |
+
st.error("Incorrect password")
|