Update app.py
Browse files
app.py
CHANGED
@@ -48,7 +48,7 @@ def encode(audio_file_path):
|
|
48 |
signal = jnp.expand_dims(signal, axis=(0, 1)) # Add batch and channel dimensions
|
49 |
|
50 |
# Set chunk duration based on available GPU memory (adjust as needed)
|
51 |
-
win_duration =
|
52 |
|
53 |
# Compress using chunking
|
54 |
dac_file = model.compress(compress_chunk, signal, sample_rate, win_duration=win_duration)
|
@@ -57,10 +57,16 @@ def encode(audio_file_path):
|
|
57 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".dac") as temp_file:
|
58 |
dac_file.save(temp_file.name)
|
59 |
|
|
|
|
|
|
|
|
|
|
|
60 |
# Return the temporary file path
|
61 |
return temp_file.name
|
62 |
|
63 |
except Exception as e:
|
|
|
64 |
gr.Warning(f"An error occurred during encoding: {e}")
|
65 |
return None
|
66 |
|
|
|
48 |
signal = jnp.expand_dims(signal, axis=(0, 1)) # Add batch and channel dimensions
|
49 |
|
50 |
# Set chunk duration based on available GPU memory (adjust as needed)
|
51 |
+
win_duration = 2.0 # Reduced win_duration for testing
|
52 |
|
53 |
# Compress using chunking
|
54 |
dac_file = model.compress(compress_chunk, signal, sample_rate, win_duration=win_duration)
|
|
|
57 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".dac") as temp_file:
|
58 |
dac_file.save(temp_file.name)
|
59 |
|
60 |
+
# Check file size
|
61 |
+
file_size = os.path.getsize(temp_file.name)
|
62 |
+
if file_size == 0:
|
63 |
+
print("WARNING: Compressed file size is 0 bytes!")
|
64 |
+
|
65 |
# Return the temporary file path
|
66 |
return temp_file.name
|
67 |
|
68 |
except Exception as e:
|
69 |
+
print(f"ERROR during encoding: {e}")
|
70 |
gr.Warning(f"An error occurred during encoding: {e}")
|
71 |
return None
|
72 |
|