Spaces:
Running
Running
admin
commited on
Commit
·
aa4a3cc
1
Parent(s):
363b58d
upl codes
Browse files- .gitattributes +10 -11
- .gitignore +2 -0
- README.md +1 -1
- app.py +113 -0
- examples/fail.mp3 +0 -0
- examples/vip.mp3 +0 -0
.gitattributes
CHANGED
@@ -1,35 +1,34 @@
|
|
1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
|
|
6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
|
|
11 |
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
13 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
17 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
|
|
20 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
22 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
|
|
24 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tfevents* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.db* filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.ark* filter=lfs diff=lfs merge=lfs -text
|
30 |
+
**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
|
31 |
+
**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
|
32 |
+
**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
flagged/*
|
2 |
+
test.py
|
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
title: Parser163
|
3 |
-
emoji:
|
4 |
colorFrom: indigo
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
title: Parser163
|
3 |
+
emoji: 🎵⬇️
|
4 |
colorFrom: indigo
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
app.py
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import re
|
3 |
+
import json
|
4 |
+
import shutil
|
5 |
+
import requests
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
|
9 |
+
def get_first_integer(input_string):
|
10 |
+
match = re.search(r"\d+", input_string)
|
11 |
+
if match:
|
12 |
+
return str(int(match.group()))
|
13 |
+
|
14 |
+
else:
|
15 |
+
return ""
|
16 |
+
|
17 |
+
|
18 |
+
def clean_dir(dirpath="./flagged"):
|
19 |
+
if os.path.exists(dirpath):
|
20 |
+
shutil.rmtree(dirpath)
|
21 |
+
|
22 |
+
if not os.path.exists(dirpath):
|
23 |
+
os.makedirs(dirpath)
|
24 |
+
|
25 |
+
|
26 |
+
def download_mp3(url: str, local_filename: str):
|
27 |
+
try:
|
28 |
+
response = requests.get(url)
|
29 |
+
if response.status_code == 200:
|
30 |
+
with open(local_filename, "wb") as f:
|
31 |
+
f.write(response.content)
|
32 |
+
|
33 |
+
print(f"Successfully downloaded: {local_filename}")
|
34 |
+
return True
|
35 |
+
|
36 |
+
else:
|
37 |
+
print(f"Error: {response.status_code}, {response.text}")
|
38 |
+
return False
|
39 |
+
|
40 |
+
except Exception as e:
|
41 |
+
print(f"Error: {e}")
|
42 |
+
return False
|
43 |
+
|
44 |
+
|
45 |
+
def song_info(id: str):
|
46 |
+
detail_api = "https://music.163.com/api/v3/song/detail"
|
47 |
+
parm_dict = {"id": id, "c": str([{"id": id}]), "csrf_token": ""}
|
48 |
+
free = False
|
49 |
+
song_name = "Failed to get song"
|
50 |
+
response = requests.get(detail_api, params=parm_dict)
|
51 |
+
# 检查请求是否成功
|
52 |
+
if response.status_code == 200:
|
53 |
+
# 处理成功响应
|
54 |
+
data = json.loads(response.text)
|
55 |
+
if data and "songs" in data and data["songs"]:
|
56 |
+
fee = int(data["songs"][0]["fee"])
|
57 |
+
free = fee == 0 or fee == 8
|
58 |
+
song_name = str(data["songs"][0]["name"])
|
59 |
+
|
60 |
+
else:
|
61 |
+
song_name = "The song doesn't exist."
|
62 |
+
|
63 |
+
else:
|
64 |
+
# 处理错误
|
65 |
+
print(f"Error: {response.status_code}, {response.text}")
|
66 |
+
|
67 |
+
return song_name, free
|
68 |
+
|
69 |
+
|
70 |
+
def inference(song: str):
|
71 |
+
api = "https://music.163.com/song/media/outer/url?id="
|
72 |
+
fail_voice = "./examples/fail.mp3"
|
73 |
+
vip_voice = "./examples/vip.mp3"
|
74 |
+
if not song:
|
75 |
+
return fail_voice, "Please enter the song ID or link", ""
|
76 |
+
|
77 |
+
song_id = song
|
78 |
+
if "music.163.com" in song_id and not ".mp3" in song_id:
|
79 |
+
song_id = get_first_integer(song_id.split("?id=")[1])
|
80 |
+
|
81 |
+
if not song_id.isdigit():
|
82 |
+
return fail_voice, "Invalid song ID or link", ""
|
83 |
+
|
84 |
+
song_name, free = song_info(song_id)
|
85 |
+
if song_name == "The song doesn't exist.":
|
86 |
+
return fail_voice, song_name, ""
|
87 |
+
|
88 |
+
clean_dir()
|
89 |
+
if free:
|
90 |
+
dld_url = f"{api}{song_id}.mp3"
|
91 |
+
outpath = f"./flagged/{song_id}.mp3"
|
92 |
+
if download_mp3(dld_url, outpath):
|
93 |
+
return outpath, song_name, dld_url
|
94 |
+
|
95 |
+
else:
|
96 |
+
return vip_voice, song_name, ""
|
97 |
+
|
98 |
+
|
99 |
+
if __name__ == "__main__":
|
100 |
+
iface = gr.Interface(
|
101 |
+
fn=inference, # 使用 text_to_speech 函数
|
102 |
+
inputs=gr.Textbox(
|
103 |
+
label="Enter the song ID or play page url"
|
104 |
+
), # 输入框用于输入文本
|
105 |
+
outputs=[
|
106 |
+
gr.Audio(label="Download mp3", type="filepath"),
|
107 |
+
gr.Textbox(label="Song title", show_copy_button=True),
|
108 |
+
gr.Textbox(label="MP3 Direct URL", show_copy_button=True),
|
109 |
+
],
|
110 |
+
flagging_mode="never",
|
111 |
+
)
|
112 |
+
|
113 |
+
iface.launch()
|
examples/fail.mp3
ADDED
Binary file (6.48 kB). View file
|
|
examples/vip.mp3
ADDED
Binary file (10.5 kB). View file
|
|