Staticaliza commited on
Commit
ef14932
·
verified ·
1 Parent(s): d7a2675

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -64,29 +64,29 @@ def build_video_omni(path):
64
 
65
  audio = build_audio(path)
66
 
67
- audio_secs = math.ceil(len(audio) / AUDIO_SR)
68
- total_units = max(1, min(len(frames), audio_secs))
69
 
70
  contents = []
71
- for i in range(total_units):
72
  frame = frames[i] if i < len(frames) else frames[-1]
73
  start = i * AUDIO_SR
74
  end = min((i + 1) * AUDIO_SR, len(audio))
75
  chunk = audio[start:end]
76
  if chunk.size == 0: break
77
- contents.extend(["<unit>", frame, chunk])
78
 
79
  return contents
80
 
81
  def build_image(path):
82
  image = Image.open(path).convert("RGB")
83
  return image
84
-
85
  def build_gif(path):
86
  image = Image.open(path)
87
  frames = [f.copy().convert("RGB") for f in ImageSequence.Iterator(image)]
88
  frames = uniform_sample(frames, MAX_FRAMES)
89
- return *frames
90
 
91
  def build_audio(path):
92
  audio, _ = librosa.load(path, sr=AUDIO_SR, mono=True)
 
64
 
65
  audio = build_audio(path)
66
 
67
+ audio_length = math.ceil(len(audio) / AUDIO_SR)
68
+ total_length = max(1, min(len(frames), audio_length))
69
 
70
  contents = []
71
+ for i in range(total_length):
72
  frame = frames[i] if i < len(frames) else frames[-1]
73
  start = i * AUDIO_SR
74
  end = min((i + 1) * AUDIO_SR, len(audio))
75
  chunk = audio[start:end]
76
  if chunk.size == 0: break
77
+ contents.extend([frame, chunk])
78
 
79
  return contents
80
 
81
  def build_image(path):
82
  image = Image.open(path).convert("RGB")
83
  return image
84
+
85
  def build_gif(path):
86
  image = Image.open(path)
87
  frames = [f.copy().convert("RGB") for f in ImageSequence.Iterator(image)]
88
  frames = uniform_sample(frames, MAX_FRAMES)
89
+ return frames
90
 
91
  def build_audio(path):
92
  audio, _ = librosa.load(path, sr=AUDIO_SR, mono=True)