Update app.py
Browse files
app.py
CHANGED
@@ -21,17 +21,17 @@ def decompress_chunk(c):
|
|
21 |
return model.apply(variables, c, method='decompress_chunk')
|
22 |
|
23 |
@spaces.GPU
|
24 |
-
def encode(
|
25 |
try:
|
26 |
-
# Load a mono audio file
|
27 |
-
signal, sample_rate = librosa.load(
|
28 |
|
29 |
signal = jnp.array(signal, dtype=jnp.float32)
|
30 |
while signal.ndim < 3:
|
31 |
signal = jnp.expand_dims(signal, axis=0)
|
32 |
|
33 |
# Set chunk duration based on available GPU memory (adjust as needed)
|
34 |
-
win_duration = 0
|
35 |
|
36 |
# Compress using chunking
|
37 |
dac_file = model.compress(compress_chunk, signal, sample_rate, win_duration=win_duration)
|
|
|
21 |
return model.apply(variables, c, method='decompress_chunk')
|
22 |
|
23 |
@spaces.GPU
|
24 |
+
def encode(audio_file):
|
25 |
try:
|
26 |
+
# Load a mono audio file directly from BytesIO
|
27 |
+
signal, sample_rate = librosa.load(audio_file, sr=44100, mono=True)
|
28 |
|
29 |
signal = jnp.array(signal, dtype=jnp.float32)
|
30 |
while signal.ndim < 3:
|
31 |
signal = jnp.expand_dims(signal, axis=0)
|
32 |
|
33 |
# Set chunk duration based on available GPU memory (adjust as needed)
|
34 |
+
win_duration = 5.0 # Start with 5 seconds
|
35 |
|
36 |
# Compress using chunking
|
37 |
dac_file = model.compress(compress_chunk, signal, sample_rate, win_duration=win_duration)
|