Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,9 @@ import random
|
|
10 |
from datetime import datetime
|
11 |
from scipy.io.wavfile import write
|
12 |
from pydub import AudioSegment
|
|
|
|
|
|
|
13 |
high_quality = True
|
14 |
|
15 |
'''
|
@@ -36,8 +39,30 @@ def svc(audio_src, audio_ref, singing_check):
|
|
36 |
|
37 |
return "output.wav"
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
def youtube_downloader(
|
40 |
-
|
41 |
start_time,
|
42 |
end_time,
|
43 |
is_full_song,
|
@@ -47,6 +72,7 @@ def youtube_downloader(
|
|
47 |
quiet=False,
|
48 |
force=True,
|
49 |
):
|
|
|
50 |
if is_full_song:
|
51 |
ydl_opts = {
|
52 |
'noplaylist': True,
|
@@ -175,7 +201,7 @@ with app:
|
|
175 |
gr.Markdown("### <center>🌊 更多精彩应用,敬请关注[滔滔AI](http://www.talktalkai.com);滔滔AI,为爱滔滔!💕</center>")
|
176 |
with gr.Row():
|
177 |
with gr.Column():
|
178 |
-
ydl_url_input = gr.Textbox(label="
|
179 |
with gr.Row():
|
180 |
start = gr.Number(value=0, label="起始时间 (秒)")
|
181 |
end = gr.Number(value=15, label="结束时间 (秒)")
|
|
|
10 |
from datetime import datetime
|
11 |
from scipy.io.wavfile import write
|
12 |
from pydub import AudioSegment
|
13 |
+
import requests
|
14 |
+
import re
|
15 |
+
|
16 |
high_quality = True
|
17 |
|
18 |
'''
|
|
|
39 |
|
40 |
return "output.wav"
|
41 |
|
42 |
+
headers = {
|
43 |
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4302.0 Safari/537.36"
|
44 |
+
}
|
45 |
+
|
46 |
+
pattern = r'//www\.bilibili\.com/video[^"]*'
|
47 |
+
|
48 |
+
def find_first_appearance_with_neighborhood(text, pattern):
|
49 |
+
match = re.search(pattern, text)
|
50 |
+
|
51 |
+
if match:
|
52 |
+
return match.group()
|
53 |
+
else:
|
54 |
+
return None
|
55 |
+
|
56 |
+
def search_bilibili(keyword):
|
57 |
+
req = requests.get("https://search.bilibili.com/all?keyword={}&duration=1&tids=3&page=1".format(keyword), headers=headers).text
|
58 |
+
|
59 |
+
video_link = "https:" + find_first_appearance_with_neighborhood(req, pattern)
|
60 |
+
|
61 |
+
return video_link
|
62 |
+
|
63 |
+
|
64 |
def youtube_downloader(
|
65 |
+
song_name,
|
66 |
start_time,
|
67 |
end_time,
|
68 |
is_full_song,
|
|
|
72 |
quiet=False,
|
73 |
force=True,
|
74 |
):
|
75 |
+
video_identifier = search_bilibili(song_name)
|
76 |
if is_full_song:
|
77 |
ydl_opts = {
|
78 |
'noplaylist': True,
|
|
|
201 |
gr.Markdown("### <center>🌊 更多精彩应用,敬请关注[滔滔AI](http://www.talktalkai.com);滔滔AI,为爱滔滔!💕</center>")
|
202 |
with gr.Row():
|
203 |
with gr.Column():
|
204 |
+
ydl_url_input = gr.Textbox(label="通过歌曲名搜索")
|
205 |
with gr.Row():
|
206 |
start = gr.Number(value=0, label="起始时间 (秒)")
|
207 |
end = gr.Number(value=15, label="结束时间 (秒)")
|