owiedotch commited on
Commit
f65c77c
1 Parent(s): d8d7a8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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(audio_file_path):
25
  try:
26
- # Load a mono audio file
27
- signal, sample_rate = librosa.load(audio_file_path, 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 = 0.5 # You might need to experiment with this value
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)