Allow for webcam uploads

#1
by multimodalart HF staff - opened
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -26,7 +26,7 @@ ZipFile("ffmpeg.zip").extractall()
26
  st = os.stat('ffmpeg')
27
  os.chmod('ffmpeg', st.st_mode | stat.S_IEXEC)
28
 
29
- def process_video(video, high_quality, target_language):
30
  # Check video duration
31
  video_info = ffmpeg.probe(video)
32
  video_duration = float(video_info['streams'][0]['duration'])
@@ -115,14 +115,22 @@ def process_video(video, high_quality, target_language):
115
 
116
  return output_video_path
117
 
 
 
 
 
 
 
 
 
118
  iface = gr.Interface(
119
  fn=process_video,
120
  inputs=[
121
- gr.Video(),
122
- gr.inputs.Checkbox(label="High Quality"),
123
- gr.inputs.Dropdown(choices=["English", "Spanish", "French", "German", "Italian", "Portuguese", "Polish", "Turkish", "Russian", "Dutch", "Czech", "Arabic", "Chinese (Simplified)"], label="Target Language for Dubbing")
124
  ],
125
- outputs=gr.outputs.Video(),
126
  live=False,
127
  title="AI Video Dubbing",
128
  description="""This tool was developed by [@artificialguybr](https://twitter.com/artificialguybr) using entirely open-source tools. Special thanks to Hugging Face for the GPU support. Thanks [@yeswondwer](https://twitter.com/@yeswondwerr) for original code.
@@ -134,5 +142,7 @@ iface = gr.Interface(
134
  - Quality can be improved but would require more processing time per video.""",
135
  allow_flagging=False
136
  )
137
-
138
- iface.launch()
 
 
 
26
  st = os.stat('ffmpeg')
27
  os.chmod('ffmpeg', st.st_mode | stat.S_IEXEC)
28
 
29
+ def process_video(radio, video, target_language):
30
  # Check video duration
31
  video_info = ffmpeg.probe(video)
32
  video_duration = float(video_info['streams'][0]['duration'])
 
115
 
116
  return output_video_path
117
 
118
+ def swap(radio):
119
+ if(radio == "Upload"):
120
+ return gr.update(source="upload")
121
+ else:
122
+ return gr.update(source="webcam")
123
+
124
+ video = gr.Video()
125
+ radio = gr.Radio(["Upload", "Record"], show_label=False)
126
  iface = gr.Interface(
127
  fn=process_video,
128
  inputs=[
129
+ radio,
130
+ video,
131
+ gr.Dropdown(choices=["English", "Spanish", "French", "German", "Italian", "Portuguese", "Polish", "Turkish", "Russian", "Dutch", "Czech", "Arabic", "Chinese (Simplified)"], label="Target Language for Dubbing")
132
  ],
133
+ outputs=gr.Video(),
134
  live=False,
135
  title="AI Video Dubbing",
136
  description="""This tool was developed by [@artificialguybr](https://twitter.com/artificialguybr) using entirely open-source tools. Special thanks to Hugging Face for the GPU support. Thanks [@yeswondwer](https://twitter.com/@yeswondwerr) for original code.
 
142
  - Quality can be improved but would require more processing time per video.""",
143
  allow_flagging=False
144
  )
145
+ with gr.Blocks() as demo:
146
+ iface.render()
147
+ radio.change(swap, inputs=[radio], outputs=video)
148
+ demo.launch()