Update app.py
Browse files
app.py
CHANGED
@@ -41,14 +41,10 @@ def encode(audio_file_path):
|
|
41 |
return None
|
42 |
|
43 |
@spaces.GPU
|
44 |
-
def decode(
|
45 |
try:
|
46 |
-
# Load encoded data from the
|
47 |
-
|
48 |
-
temp_file.write(compressed_file.file.read())
|
49 |
-
temp_file_path = temp_file.name
|
50 |
-
|
51 |
-
data = np.load(temp_file_path)
|
52 |
z = data['z']
|
53 |
codes = data['codes']
|
54 |
latents = data['latents']
|
@@ -61,7 +57,6 @@ def decode(compressed_file):
|
|
61 |
y = y * db2linear(input_db - (-16)) # Using -16 as the target_db
|
62 |
|
63 |
decoded_audio = np.array(y).squeeze()
|
64 |
-
os.unlink(temp_file_path)
|
65 |
return (44100, decoded_audio)
|
66 |
|
67 |
except Exception as e:
|
|
|
41 |
return None
|
42 |
|
43 |
@spaces.GPU
|
44 |
+
def decode(compressed_file_path): # Changed input to compressed_file_path
|
45 |
try:
|
46 |
+
# Load encoded data directly from the file path
|
47 |
+
data = np.load(compressed_file_path) # No need for temporary files
|
|
|
|
|
|
|
|
|
48 |
z = data['z']
|
49 |
codes = data['codes']
|
50 |
latents = data['latents']
|
|
|
57 |
y = y * db2linear(input_db - (-16)) # Using -16 as the target_db
|
58 |
|
59 |
decoded_audio = np.array(y).squeeze()
|
|
|
60 |
return (44100, decoded_audio)
|
61 |
|
62 |
except Exception as e:
|