Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,24 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import ffmpeg
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
+
def extract_audio(video):
|
| 6 |
+
input_path = video.name
|
| 7 |
+
out_audio = "audio.wav"
|
| 8 |
+
(
|
| 9 |
+
ffmpeg
|
| 10 |
+
.input(input_path)
|
| 11 |
+
.output(out_audio, ac=1, ar=16000, format="wav")
|
| 12 |
+
.overwrite_output()
|
| 13 |
+
.run(quiet=True)
|
| 14 |
+
)
|
| 15 |
+
return out_audio # returns audio file for download
|
| 16 |
+
|
| 17 |
+
with gr.Blocks() as demo:
|
| 18 |
+
gr.Markdown("# Dubbing Prototype: Step 1 (extract audio)")
|
| 19 |
+
video_in = gr.Video(label="Upload video")
|
| 20 |
+
audio_out = gr.Audio(label="Extracted audio")
|
| 21 |
+
btn = gr.Button("Extract audio")
|
| 22 |
+
btn.click(fn=extract_audio, inputs=video_in, outputs=audio_out)
|
| 23 |
|
|
|
|
| 24 |
demo.launch()
|