fffiloni commited on
Commit
f694503
β€’
1 Parent(s): 91b6aef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
-
3
  from share_btn import community_icon_html, loading_icon_html, share_js
4
 
5
  caption = gr.Blocks.load(name="spaces/SRDdev/Image-Caption")
@@ -8,7 +8,10 @@ audio_gen = gr.Blocks.load(name="spaces/haoheliu/audioldm-text-to-audio-generati
8
  def infer(image_input):
9
  cap = caption(image_input, fn_index=0)
10
  sound = audio_gen(cap, 5, 2.5, 45, 3, fn_index=0)
11
- return gr.Textbox.update(value=cap, visible=True), sound, gr.Group.update(visible=True)
 
 
 
12
 
13
  title = """
14
  <div style="text-align: center; max-width: 700px; margin: 0 auto;">
@@ -47,7 +50,7 @@ with gr.Blocks(css="style.css") as demo:
47
 
48
  input_img = gr.Image(type="filepath", elem_id="input-img")
49
  caption_output = gr.Textbox(label="Caption", lines=1, visible=False, elem_id="text-caption")
50
- sound_output = gr.Video(label="Result", elem_id="sound-output")
51
 
52
  generate = gr.Button("Generate SFX from Image")
53
 
 
1
  import gradio as gr
2
+ from moviepy.editor import *
3
  from share_btn import community_icon_html, loading_icon_html, share_js
4
 
5
  caption = gr.Blocks.load(name="spaces/SRDdev/Image-Caption")
 
8
  def infer(image_input):
9
  cap = caption(image_input, fn_index=0)
10
  sound = audio_gen(cap, 5, 2.5, 45, 3, fn_index=0)
11
+ FILETOCONVERT = AudioFileClip(sound)
12
+ FILETOCONVERT.write_audiofile("audio.wav")
13
+ FILETOCONVERT.close()
14
+ return gr.Textbox.update(value=cap, visible=True), "audio.wav", gr.Group.update(visible=True)
15
 
16
  title = """
17
  <div style="text-align: center; max-width: 700px; margin: 0 auto;">
 
50
 
51
  input_img = gr.Image(type="filepath", elem_id="input-img")
52
  caption_output = gr.Textbox(label="Caption", lines=1, visible=False, elem_id="text-caption")
53
+ sound_output = gr.Audio(label="Result", elem_id="sound-output")
54
 
55
  generate = gr.Button("Generate SFX from Image")
56