limit input length

#2
by linoyts HF staff - opened
Files changed (2) hide show
  1. app.py +1 -17
  2. utils.py +1 -1
app.py CHANGED
@@ -71,15 +71,6 @@ def sample(ldm_stable, zs, wts, steps, prompt_tar, tstart, cfg_scale_tar): # ,
71
  return f.name
72
 
73
 
74
- # def change_tstart_range(t_start, steps):
75
- # maximum = int(0.8 * steps)
76
- # minimum = int(0.15 * steps)
77
- # if t_start > maximum:
78
- # t_start = maximum
79
- # elif t_start < minimum:
80
- # t_start = minimum
81
- # return t_start
82
-
83
 
84
  def edit(input_audio,
85
  model_id: str,
@@ -93,13 +84,6 @@ def edit(input_audio,
93
  t_start=45,
94
  randomize_seed=True):
95
 
96
- # global ldm_stable, current_loaded_model
97
- # print(f'current loaded model: {ldm_stable.model_id}')
98
- # if model_id != current_loaded_model:
99
- # print(f'Changing model to {model_id}...')
100
- # current_loaded_model = model_id
101
- # ldm_stable = None
102
- # ldm_stable = load_model(model_id, device)
103
  print(model_id)
104
  if model_id == LDM2:
105
  ldm_stable = ldm2
@@ -219,7 +203,7 @@ with gr.Blocks(css='style.css') as demo:
219
  do_inversion = gr.State(value=True) # To save some runtime when editing the same thing over and over
220
 
221
  with gr.Row():
222
- input_audio = gr.Audio(sources=["upload", "microphone"], max_length=15, type="filepath", label="Input Audio",
223
  interactive=True, scale=1)
224
  output_audio = gr.Audio(label="Edited Audio", interactive=False, scale=1)
225
 
 
71
  return f.name
72
 
73
 
 
 
 
 
 
 
 
 
 
74
 
75
  def edit(input_audio,
76
  model_id: str,
 
84
  t_start=45,
85
  randomize_seed=True):
86
 
 
 
 
 
 
 
 
87
  print(model_id)
88
  if model_id == LDM2:
89
  ldm_stable = ldm2
 
203
  do_inversion = gr.State(value=True) # To save some runtime when editing the same thing over and over
204
 
205
  with gr.Row():
206
+ input_audio = gr.Audio(sources=["upload", "microphone"], type="filepath", label="Input Audio",
207
  interactive=True, scale=1)
208
  output_audio = gr.Audio(label="Edited Audio", interactive=False, scale=1)
209
 
utils.py CHANGED
@@ -16,7 +16,7 @@ def load_audio(audio_path: Union[str, np.array], fn_STFT, left: int = 0, right:
16
  import audioldm
17
  import audioldm.audio
18
 
19
- duration = audioldm.utils.get_duration(audio_path)
20
 
21
  mel, _, _ = audioldm.audio.wav_to_fbank(audio_path, target_length=int(duration * 102.4), fn_STFT=fn_STFT)
22
  mel = mel.unsqueeze(0)
 
16
  import audioldm
17
  import audioldm.audio
18
 
19
+ duration = min(audioldm.utils.get_duration(audio_path), 15)
20
 
21
  mel, _, _ = audioldm.audio.wav_to_fbank(audio_path, target_length=int(duration * 102.4), fn_STFT=fn_STFT)
22
  mel = mel.unsqueeze(0)