Spaces:
Runtime error
Runtime error
Kangarroar
commited on
Commit
•
b7be665
1
Parent(s):
22971e6
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import tempfile
|
3 |
+
|
4 |
+
st.title('DIFF-SVC Render')
|
5 |
+
|
6 |
+
###CKPT LOADER
|
7 |
+
# File uploader
|
8 |
+
ckpt = st.file_uploader("Choose your CKPT", type= 'ckpt')
|
9 |
+
|
10 |
+
# Check if user uploaded a CKPT file
|
11 |
+
if ckpt is not None:
|
12 |
+
#TEMP FUNCTION
|
13 |
+
with tempfile.NamedTemporaryFile(mode="wb", suffix='.ckpt', delete=False) as temp:
|
14 |
+
# Get the file contents as bytes
|
15 |
+
bytes_data = ckpt.getvalue()
|
16 |
+
# Write the bytes to the temporary file
|
17 |
+
temp.write(bytes_data)
|
18 |
+
ckpt_temp_file = temp.name
|
19 |
+
# Print the temporary file name
|
20 |
+
print(temp.name)
|
21 |
+
|
22 |
+
# Display the file path
|
23 |
+
if "ckpt_temp_file" in locals():
|
24 |
+
st.success("File saved to: {}".format(ckpt_temp_file))
|
25 |
+
|
26 |
+
# File uploader
|
27 |
+
config = st.file_uploader("Choose your config", type= 'yaml')
|
28 |
+
|
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 |
+
|
41 |
+
# Display the file path
|
42 |
+
if "config_temp_file" in locals():
|
43 |
+
st.success("File saved to: {}".format(config_temp_file))
|
44 |
+
|
45 |
+
# File uploader
|
46 |
+
audio = st.file_uploader("Choose your audio", type=["wav", "mp3"])
|
47 |
+
|
48 |
+
# Check if user uploaded an audio file
|
49 |
+
if audio is not None:
|
50 |
+
#TEMP FUNCTION
|
51 |
+
with tempfile.NamedTemporaryFile(mode="wb", suffix='.wav', delete=False) as temp:
|
52 |
+
# Get the file contents as bytes
|
53 |
+
bytes_data = audio.getvalue()
|
54 |
+
# Write the bytes to the temporary file
|
55 |
+
temp.write(bytes_data)
|
56 |
+
audio_temp_file = temp.name
|
57 |
+
# Print the temporary file name
|
58 |
+
print(temp.name)
|
59 |
+
|
60 |
+
# Display the file path
|
61 |
+
if "audio_temp_file" in locals():
|
62 |
+
st.success("File saved to: {}".format(audio_temp_file))
|
63 |
+
# Add a text input for the title with a default value of 0
|
64 |
+
title = st.text_input("Key", value="0")
|
65 |
+
# Add a button to start the rendering process
|
66 |
+
if st.button("Render audio"):
|
67 |
+
render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title)
|