Update run.py
Browse files
run.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import subprocess
|
|
|
4 |
|
5 |
def get_video_title(url):
|
6 |
# 使用 yt-dlp 获取视频标题
|
@@ -26,15 +27,24 @@ def fetch(url, custom_name, ext):
|
|
26 |
|
27 |
return filename
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
app = gr.Interface(
|
30 |
theme='Hev832/EasyAndCool',
|
31 |
-
fn=fetch,
|
32 |
inputs=[
|
33 |
gr.Textbox(label="YouTube video address", placeholder="Paste video link here..."),
|
34 |
gr.Textbox(label="file name", placeholder="Defaults to video title"),
|
35 |
gr.Dropdown(value="wav", label="format")
|
36 |
],
|
37 |
outputs=gr.File(label="Download the file!"),
|
|
|
|
|
38 |
description="<div style='font-size:30px; text-align:center;'>YouTube wav downloader</div>"
|
39 |
)
|
40 |
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import subprocess
|
4 |
+
from IPython.display import Audio
|
5 |
|
6 |
def get_video_title(url):
|
7 |
# 使用 yt-dlp 获取视频标题
|
|
|
27 |
|
28 |
return filename
|
29 |
|
30 |
+
|
31 |
+
def play_audio():
|
32 |
+
audio_file_path = {filename}
|
33 |
+
return Audio(audio_file_path)
|
34 |
+
|
35 |
+
iface = gr.Interface(
|
36 |
+
|
37 |
app = gr.Interface(
|
38 |
theme='Hev832/EasyAndCool',
|
39 |
+
fn=fetch, fn=play_audio,
|
40 |
inputs=[
|
41 |
gr.Textbox(label="YouTube video address", placeholder="Paste video link here..."),
|
42 |
gr.Textbox(label="file name", placeholder="Defaults to video title"),
|
43 |
gr.Dropdown(value="wav", label="format")
|
44 |
],
|
45 |
outputs=gr.File(label="Download the file!"),
|
46 |
+
show=True,
|
47 |
+
capture_session=True),
|
48 |
description="<div style='font-size:30px; text-align:center;'>YouTube wav downloader</div>"
|
49 |
)
|
50 |
|