thecollabagepatch commited on
Commit
8cf69d0
·
1 Parent(s): ede0049

loop_duration_seconds returned

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -293,6 +293,13 @@ def generate(
293
  loudness_headroom_db=loudness_headroom_db,
294
  )
295
 
 
 
 
 
 
 
 
296
  # Return base64 WAV + minimal metadata
297
  buf = io.BytesIO()
298
  # add format="WAV" when writing to a file-like object
@@ -310,9 +317,15 @@ def generate(
310
  "style_weights": weights,
311
  "loop_weight": loop_weight,
312
  "loudness": loud_stats,
313
- "sample_rate": mrt.sample_rate,
314
  "channels": mrt.num_channels,
315
  "crossfade_seconds": mrt.config.crossfade_length,
 
 
 
 
 
 
316
  # Echo the actual knobs used
317
  "guidance_weight": guidance_weight,
318
  "temperature": temperature,
 
293
  loudness_headroom_db=loudness_headroom_db,
294
  )
295
 
296
+ total_samples = int(wav.samples.shape[0])
297
+ sample_rate = int(get_mrt().sample_rate) # or mrt.sample_rate (same instance here)
298
+ loop_duration_seconds = total_samples / float(sample_rate)
299
+
300
+ # Also include the bar math (useful for sanity checks downstream)
301
+ seconds_per_bar = (60.0 / float(bpm)) * int(beats_per_bar)
302
+
303
  # Return base64 WAV + minimal metadata
304
  buf = io.BytesIO()
305
  # add format="WAV" when writing to a file-like object
 
317
  "style_weights": weights,
318
  "loop_weight": loop_weight,
319
  "loudness": loud_stats,
320
+ "sample_rate": sample_rate,
321
  "channels": mrt.num_channels,
322
  "crossfade_seconds": mrt.config.crossfade_length,
323
+
324
+ # New timing fields
325
+ "total_samples": total_samples,
326
+ "seconds_per_bar": seconds_per_bar,
327
+ "loop_duration_seconds": loop_duration_seconds,
328
+
329
  # Echo the actual knobs used
330
  "guidance_weight": guidance_weight,
331
  "temperature": temperature,