ziqiangao commited on
Commit
5683224
·
1 Parent(s): d940837

update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -169,12 +169,13 @@ def stripinvisibles(s):
169
  for i in invisible_chars:
170
  e.replace(i,"")
171
  return e
172
-
173
  def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics=None, img=None, tit=None, ast=None):
174
  p = gr.Progress()
175
  LRC2SRT.clear()
176
  if os.path.exists("out.srt"):
177
  os.remove("out.srt")
 
178
  haslyrics = False
179
  if lyrics:
180
  p(0.5,"parsing lyrics")
@@ -289,7 +290,11 @@ def gradio_interface(audio_file, lyrics, output_name, fps=30, vidwidth=1280, vid
289
  time.sleep(5)
290
 
291
  shutil.rmtree("out")
292
- return f"{output_name}.mp4"
 
 
 
 
293
 
294
  with gr.Blocks() as inputs:
295
  gr.Markdown('Upload an MP3 file and configure parameters to create a visualization video.\nOptionally upload a word or line synced lyric file\nEnsure a blank line at the end to avoid conversion errors')
@@ -315,7 +320,7 @@ with gr.Blocks() as inputs:
315
  iface = gr.Interface(
316
  fn=gradio_interface,
317
  inputs=inputs,
318
- outputs=gr.components.Video(label="Output"),
319
  )
320
 
321
  # Launch Gradio interface
 
169
  for i in invisible_chars:
170
  e.replace(i,"")
171
  return e
172
+ haslyrics = False
173
  def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics=None, img=None, tit=None, ast=None):
174
  p = gr.Progress()
175
  LRC2SRT.clear()
176
  if os.path.exists("out.srt"):
177
  os.remove("out.srt")
178
+ global haslyrics
179
  haslyrics = False
180
  if lyrics:
181
  p(0.5,"parsing lyrics")
 
290
  time.sleep(5)
291
 
292
  shutil.rmtree("out")
293
+ if haslyrics:
294
+ w = "out.srt"
295
+ else:
296
+ w = None
297
+ return f"{output_name}.mp4",
298
 
299
  with gr.Blocks() as inputs:
300
  gr.Markdown('Upload an MP3 file and configure parameters to create a visualization video.\nOptionally upload a word or line synced lyric file\nEnsure a blank line at the end to avoid conversion errors')
 
320
  iface = gr.Interface(
321
  fn=gradio_interface,
322
  inputs=inputs,
323
+ outputs=[gr.components.Video(label="Output"),gr.components.File(label="SRT Output")]
324
  )
325
 
326
  # Launch Gradio interface