BoldActionMan commited on
Commit
2fe9bc4
1 Parent(s): a818c02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -15,10 +15,12 @@ from concurrent.futures import ThreadPoolExecutor
15
  import ffmpeg
16
 
17
  def process_video(video_file, youtube_url, language_choice):
18
- if language_choice == None or (video_file == None and youtube_url == None):
19
- return None
20
- if video_file != None and youtube_url != None:
21
- return None
 
 
22
  elif video_file == None and youtube_url != None:
23
  yt = YouTube(youtube_url)
24
  yt.streams.filter(progressive=True, file_extension='mp4').first().download(filename="original.mp4")
@@ -103,7 +105,7 @@ def process_video(video_file, youtube_url, language_choice):
103
  print(e.stderr.decode('utf-8'))
104
 
105
  print(f"Final video with subtitles saved to: {final_video_with_subs_path}")
106
- return final_video_with_subs_path
107
  else:
108
  target_se, audio_name = se_extractor.get_se(reference_speaker, tone_color_converter, vad=False)
109
 
@@ -252,7 +254,7 @@ def process_video(video_file, youtube_url, language_choice):
252
 
253
  print(f"Final video with subtitles saved to: {final_video_with_subs_path}")
254
 
255
- return final_video_with_subs_path
256
 
257
  #Gradio Interface
258
  language_choices = ts.get_languages("google")["en"]
@@ -265,7 +267,10 @@ gr.Interface(
265
  gr.Textbox(label="OR enter a YouTube video URL"),
266
  gr.Dropdown(choices=language_choices, label="Choose Language for Translation (Expressed in ISO 639-1 code)")
267
  ],
268
- outputs=gr.Video(label="Translated Video", format='mp4'),
 
 
 
269
  title="Video Translation and Voice Cloning",
270
  description="Upload a video, choose a language to translate the audio, and download the processed video with translated audio."
271
  ).launch()
 
15
  import ffmpeg
16
 
17
  def process_video(video_file, youtube_url, language_choice):
18
+ if language_choice == None:
19
+ return None, "Select a language to translate to."
20
+ elif video_file == None and youtube_url == None:
21
+ return None, "Upload either a video or a valid youtube URL."
22
+ elif video_file != None and youtube_url != None:
23
+ return None, "Videos contradict. Delete either the uploaded video or youtube URL."
24
  elif video_file == None and youtube_url != None:
25
  yt = YouTube(youtube_url)
26
  yt.streams.filter(progressive=True, file_extension='mp4').first().download(filename="original.mp4")
 
105
  print(e.stderr.decode('utf-8'))
106
 
107
  print(f"Final video with subtitles saved to: {final_video_with_subs_path}")
108
+ return final_video_with_subs_path, "Video language and language selection are the same, audio not changed."
109
  else:
110
  target_se, audio_name = se_extractor.get_se(reference_speaker, tone_color_converter, vad=False)
111
 
 
254
 
255
  print(f"Final video with subtitles saved to: {final_video_with_subs_path}")
256
 
257
+ return final_video_with_subs_path, "Video successfully translated."
258
 
259
  #Gradio Interface
260
  language_choices = ts.get_languages("google")["en"]
 
267
  gr.Textbox(label="OR enter a YouTube video URL"),
268
  gr.Dropdown(choices=language_choices, label="Choose Language for Translation (Expressed in ISO 639-1 code)")
269
  ],
270
+ outputs=[
271
+ gr.Video(label="Translated Video", format='mp4'),
272
+ gr.Textbox(label=None)
273
+ ],
274
  title="Video Translation and Voice Cloning",
275
  description="Upload a video, choose a language to translate the audio, and download the processed video with translated audio."
276
  ).launch()