fffiloni commited on
Commit
ce3ce04
β€’
1 Parent(s): 347dc6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -11,15 +11,19 @@ audio_gen = gr.Blocks.load(name="spaces/fffiloni/audioldm-text-to-audio-generati
11
  ph_message="If you're not happy with sound result, you can manually describe the scene depicted in your image :)"
12
 
13
  def input_changes(input_img):
 
 
14
  if input_img == None:
15
  return manual_cap.update(value="",placeholder=ph_message), caption_output.update(value=None), sound_output.update(value=None)
16
  else:
17
  cap = caption(input_img, fn_index=0)
18
  print("gpt2 caption: '" + cap + "' β€’ ")
19
  ph_update = "gpt2 caption: '" + cap + "' β€’ "
 
20
  return manual_cap.update(value="",placeholder=f"{ph_update}{ph_message}"), caption_output.update(value=cap), sound_output.update(value=None)
21
 
22
  def infer(image_input, manual_caption, duration_in, seed, caption_output):
 
23
  print(duration_in)
24
  if manual_caption == "":
25
  cap = caption_output
@@ -100,7 +104,7 @@ with gr.Blocks(css="style.css") as demo:
100
  seed_in = gr.Slider(label="Seed", value=440, minimum=45, maximum=10000, step=1)
101
 
102
  caption_output = gr.Textbox(label="Caption", visible=False, elem_id="text-caption")
103
- sound_output = gr.Audio(label="Result", elem_id="sound-output")
104
 
105
  generate = gr.Button("Generate SFX from Image")
106
 
 
11
  ph_message="If you're not happy with sound result, you can manually describe the scene depicted in your image :)"
12
 
13
  def input_changes(input_img):
14
+ sound_output.update(visible=False)
15
+
16
  if input_img == None:
17
  return manual_cap.update(value="",placeholder=ph_message), caption_output.update(value=None), sound_output.update(value=None)
18
  else:
19
  cap = caption(input_img, fn_index=0)
20
  print("gpt2 caption: '" + cap + "' β€’ ")
21
  ph_update = "gpt2 caption: '" + cap + "' β€’ "
22
+
23
  return manual_cap.update(value="",placeholder=f"{ph_update}{ph_message}"), caption_output.update(value=cap), sound_output.update(value=None)
24
 
25
  def infer(image_input, manual_caption, duration_in, seed, caption_output):
26
+ sound_output.update(visible=True)
27
  print(duration_in)
28
  if manual_caption == "":
29
  cap = caption_output
 
104
  seed_in = gr.Slider(label="Seed", value=440, minimum=45, maximum=10000, step=1)
105
 
106
  caption_output = gr.Textbox(label="Caption", visible=False, elem_id="text-caption")
107
+ sound_output = gr.Audio(label="Result", visible=False, elem_id="sound-output")
108
 
109
  generate = gr.Button("Generate SFX from Image")
110