Spaces:
Runtime error
Runtime error
import streamlit as st | |
import tempfile | |
st.title('DIFF-SVC Render') | |
###CKPT LOADER | |
# File uploader | |
ckpt = st.file_uploader("Choose your CKPT", type= 'ckpt') | |
# Check if user uploaded a CKPT file | |
if ckpt is not None: | |
#TEMP FUNCTION | |
with tempfile.NamedTemporaryFile(mode="wb", suffix='.ckpt', delete=False) as temp: | |
# Get the file contents as bytes | |
bytes_data = ckpt.getvalue() | |
# Write the bytes to the temporary file | |
temp.write(bytes_data) | |
ckpt_temp_file = temp.name | |
# Print the temporary file name | |
print(temp.name) | |
# Display the file path | |
if "ckpt_temp_file" in locals(): | |
st.success("File saved to: {}".format(ckpt_temp_file)) | |
# File uploader | |
config = st.file_uploader("Choose your config", type= 'yaml') | |
# Check if user uploaded a config file | |
if config is not None: | |
#TEMP FUNCTION | |
with tempfile.NamedTemporaryFile(mode="wb", suffix='.yaml', delete=False) as temp: | |
# Get the file contents as bytes | |
bytes_data = config.getvalue() | |
# Write the bytes to the temporary file | |
temp.write(bytes_data) | |
config_temp_file = temp.name | |
# Print the temporary file name | |
print(temp.name) | |
# Display the file path | |
if "config_temp_file" in locals(): | |
st.success("File saved to: {}".format(config_temp_file)) | |
# File uploader | |
audio = st.file_uploader("Choose your audio", type=["wav", "mp3"]) | |
# Check if user uploaded an audio file | |
if audio is not None: | |
#TEMP FUNCTION | |
with tempfile.NamedTemporaryFile(mode="wb", suffix='.wav', delete=False) as temp: | |
# Get the file contents as bytes | |
bytes_data = audio.getvalue() | |
# Write the bytes to the temporary file | |
temp.write(bytes_data) | |
audio_temp_file = temp.name | |
# Print the temporary file name | |
print(temp.name) | |
# Display the file path | |
if "audio_temp_file" in locals(): | |
st.success("File saved to: {}".format(audio_temp_file)) | |
# Add a text input for the title with a default value of 0 | |
title = st.text_input("Key", value="0") | |
# Add a button to start the rendering process | |
if st.button("Render audio"): | |
render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title) | |