Spaces:
Configuration error
Configuration error
Commit
·
d8a47b1
1
Parent(s):
2d5ca02
Update app.py
Browse files
app.py
CHANGED
|
@@ -106,18 +106,18 @@ with tempfile.TemporaryDirectory(dir=os.path.expanduser("~/app")) as temp_dir:
|
|
| 106 |
# Check if user uploaded an audio file
|
| 107 |
if audio is not None:
|
| 108 |
#TEMP FUNCTION
|
| 109 |
-
|
| 110 |
# Get the file contents as bytes
|
| 111 |
-
|
| 112 |
# Write the bytes to the temporary file
|
| 113 |
-
|
| 114 |
-
|
| 115 |
# Print the temporary file name
|
| 116 |
-
|
| 117 |
|
| 118 |
# Display the file path
|
| 119 |
if "audio_temp_file" in locals():
|
| 120 |
-
|
| 121 |
# Add a text input for the title with a default value of 0
|
| 122 |
title = st.text_input("Key", value="0")
|
| 123 |
# Add a button to start the rendering process
|
|
|
|
| 106 |
# Check if user uploaded an audio file
|
| 107 |
if audio is not None:
|
| 108 |
#TEMP FUNCTION
|
| 109 |
+
with tempfile.NamedTemporaryFile(mode="wb", suffix='.wav', delete=False, dir=temp_dir) as temp:
|
| 110 |
# Get the file contents as bytes
|
| 111 |
+
bytes_data = audio.getvalue()
|
| 112 |
# Write the bytes to the temporary file
|
| 113 |
+
temp.write(bytes_data)
|
| 114 |
+
audio_temp_file = temp.name
|
| 115 |
# Print the temporary file name
|
| 116 |
+
print(temp.name)
|
| 117 |
|
| 118 |
# Display the file path
|
| 119 |
if "audio_temp_file" in locals():
|
| 120 |
+
st.success("File saved to: {}".format(audio_temp_file))
|
| 121 |
# Add a text input for the title with a default value of 0
|
| 122 |
title = st.text_input("Key", value="0")
|
| 123 |
# Add a button to start the rendering process
|