kevinwang676 commited on
Commit
8dc2b8f
·
verified ·
1 Parent(s): 9965f6c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +130 -35
app.py CHANGED
@@ -10,38 +10,102 @@ import traceback
10
  from pydub import AudioSegment
11
  # from audio_enhance.functions import audio_enhance
12
 
13
- def convert_yt_to_wav(url):
14
- if not url:
15
- return "Primero introduce el enlace del video", None
16
-
17
- try:
18
- print(f"Convirtiendo video {url}...")
19
- # Descargar el video utilizando pytube
20
- video = pytube.YouTube(url)
21
- stream = video.streams.filter(only_audio=True).first()
22
- video_output_folder = os.path.join(f"yt_videos") # Ruta de destino de la carpeta
23
- audio_output_folder = 'audios'
24
-
25
- print("Downloading video")
26
- video_file_path = stream.download(output_path=video_output_folder)
27
- print(video_file_path)
28
-
29
- file_name = os.path.basename(video_file_path)
30
-
31
- audio_file_path = os.path.join(audio_output_folder, file_name.replace('.mp4','.wav'))
32
- # convert mp4 to wav
33
- print("Converting to wav")
34
- sound = AudioSegment.from_file(video_file_path,format="mp4")
35
- sound.export(audio_file_path, format="wav")
36
-
37
- if os.path.exists(video_file_path):
38
- os.remove(video_file_path)
39
-
40
- return "Success", audio_file_path
41
- except ConnectionResetError as cre:
42
- return "Se ha perdido la conexión, recarga o reintentalo nuevamente más tarde.", None
43
- except Exception as e:
44
- return str(e), None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
 
47
  title_markdown = ("""
@@ -54,11 +118,11 @@ pic_markdown = ("""
54
  <h1 align="center"><a href="https://www.talktalkai.com/"><img src="https://download.openxlab.org.cn/models/Kevin676/rvc-models/weight/talktalkai-cover.png", alt="talktalkai-cover" border="0" style="margin: 0 auto; height: 300px;" /></a> </h1>
55
  """)
56
 
57
- with gr.Blocks() as app:
58
 
59
  gr.Markdown(title_markdown)
60
 
61
- with gr.Tab("模型搜索及上传"):
62
  gr.HTML("<h3>1. 搜索AI歌手模型</h3>")
63
  gr.Markdown("##### 点击[此链接](https://docs.google.com/spreadsheets/d/1owfUtQuLW9ReiIwg6U9UkkDmPOTkuNHf0OKQtWu1iaI/edit?gid=1227575351#gid=1227575351),查看全网所有开源AI歌手模型,超9000个模型任您挑选 🥳")
64
  search_name = gr.Textbox(placeholder="孙燕姿", label="请填写模型名称进行搜索", show_label=True)
@@ -82,7 +146,38 @@ with gr.Blocks() as app:
82
 
83
  btn_post_model = gr.Button(value="开始上传吧💕", variant="primary")
84
  btn_post_model.click(fn=post_model, inputs=[post_name, post_model_url, post_version, post_creator], outputs=[post_output])
85
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  gr.Markdown(pic_markdown)
87
  gr.Markdown("###### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。请自觉合规使用此程序,程序开发者不负有任何责任。</center>")
88
 
 
10
  from pydub import AudioSegment
11
  # from audio_enhance.functions import audio_enhance
12
 
13
+ import ast
14
+ import argparse
15
+ import glob
16
+ import pickle
17
+
18
+ import numpy as np
19
+ import pandas as pd
20
+ block_css = """
21
+ #notice_markdown {
22
+ font-size: 104%
23
+ }
24
+ #notice_markdown th {
25
+ display: none;
26
+ }
27
+ #notice_markdown td {
28
+ padding-top: 6px;
29
+ padding-bottom: 6px;
30
+ }
31
+ #leaderboard_markdown {
32
+ font-size: 104%
33
+ }
34
+ #leaderboard_markdown td {
35
+ padding-top: 6px;
36
+ padding-bottom: 6px;
37
+ }
38
+ #leaderboard_dataframe td {
39
+ line-height: 0.1em;
40
+ }
41
+ footer {
42
+ display:none !important
43
+ }
44
+ .image-container {
45
+ display: flex;
46
+ align-items: center;
47
+ padding: 1px;
48
+ }
49
+ .image-container img {
50
+ margin: 0 30px;
51
+ height: 20px;
52
+ max-height: 100%;
53
+ width: auto;
54
+ max-width: 20%;
55
+ }
56
+ """
57
+ def model_hyperlink(model_name, link):
58
+ return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
59
+ def load_leaderboard_table_csv(filename, add_hyperlink=True):
60
+ lines = open(filename).readlines()
61
+ heads = [v.strip() for v in lines[0].split(",")]
62
+ rows = []
63
+ for i in range(1, len(lines)):
64
+ row = [v.strip() for v in lines[i].split(",")]
65
+ for j in range(len(heads)):
66
+ item = {}
67
+ for h, v in zip(heads, row):
68
+ if h != "AI歌手名/AI Singer" and h != "歌手代表作或介绍链接" and h != "模型zip链接/Link to Model Zip File" and h != "模型贡献者/Model Contributor":
69
+ item[h] = int(v)
70
+ else:
71
+ item[h] = v
72
+ if add_hyperlink:
73
+ item["AI歌手名/AI Singer"] = model_hyperlink(item["AI歌手名/AI Singer"], item["歌手代表作或介绍链接"])
74
+ rows.append(item)
75
+ return rows
76
+
77
+ def get_arena_table(model_table_df):
78
+ # sort by rating
79
+ model_table_df = model_table_df.sort_values(by=["训练素材时长/Duration of Training Dataset(min)"], ascending=False)
80
+ values = []
81
+ for i in range(len(model_table_df)):
82
+ row = []
83
+ model_key = model_table_df.index[i]
84
+ model_name = model_table_df["AI歌手名/AI Singer"].values[model_key]
85
+ # rank
86
+ row.append(i + 1)
87
+ # model display name
88
+ row.append(model_name)
89
+
90
+ row.append(
91
+ model_table_df["模型zip链接/Link to Model Zip File"].values[model_key]
92
+ )
93
+
94
+ row.append(
95
+ model_table_df["训练素材时长/Duration of Training Dataset(min)"].values[model_key]
96
+ )
97
+
98
+ row.append(
99
+ model_table_df["训练epoch数/Epoch"].values[model_key]
100
+ )
101
+
102
+ row.append(
103
+ model_table_df["模型贡献者/Model Contributor"].values[model_key]
104
+ )
105
+
106
+ values.append(row)
107
+ return values
108
+
109
 
110
 
111
  title_markdown = ("""
 
118
  <h1 align="center"><a href="https://www.talktalkai.com/"><img src="https://download.openxlab.org.cn/models/Kevin676/rvc-models/weight/talktalkai-cover.png", alt="talktalkai-cover" border="0" style="margin: 0 auto; height: 300px;" /></a> </h1>
119
  """)
120
 
121
+ with gr.Blocks(theme="JohnSmith9982/small_and_pretty", css=block_css) as app:
122
 
123
  gr.Markdown(title_markdown)
124
 
125
+ with gr.Tab("✨模型搜索及上传"):
126
  gr.HTML("<h3>1. 搜索AI歌手模型</h3>")
127
  gr.Markdown("##### 点击[此链接](https://docs.google.com/spreadsheets/d/1owfUtQuLW9ReiIwg6U9UkkDmPOTkuNHf0OKQtWu1iaI/edit?gid=1227575351#gid=1227575351),查看全网所有开源AI歌手模型,超9000个模型任您挑选 🥳")
128
  search_name = gr.Textbox(placeholder="孙燕姿", label="请填写模型名称进行搜索", show_label=True)
 
146
 
147
  btn_post_model = gr.Button(value="开始上传吧💕", variant="primary")
148
  btn_post_model.click(fn=post_model, inputs=[post_name, post_model_url, post_version, post_creator], outputs=[post_output])
149
+
150
+ with gr.Tab("🍻滔滔AI精选模型"):
151
+ arena_table_vals = get_arena_table(model_table_df)
152
+ md = """
153
+ AI翻唱🎶:您可以在社区中复制您喜欢的AI歌手的“模型zip链接”,之后就可以在“🌟重磅首发 - AI歌手全明星💕”页面中通过粘贴zip链接来使用您喜欢的AI歌手模型啦!\n
154
+ [手机端📱](https://kevinwang676-talktalkai-models.hf.space)查看滔滔AI精选模型
155
+ """
156
+ gr.Markdown(md, elem_id="leaderboard_markdown")
157
+ gr.Dataframe(
158
+ headers=[
159
+ "排序",
160
+ "AI歌手名/AI Singer",
161
+ "模型zip链接/Link to Model Zip File",
162
+ "训练素材时长/Duration of Training Dataset(min)",
163
+ "训练epoch数/Epoch",
164
+ "模型贡献者/Model Contributor",
165
+ ],
166
+ datatype=[
167
+ "str",
168
+ "markdown",
169
+ "str",
170
+ "number",
171
+ "number",
172
+ "str",
173
+ ],
174
+ value=arena_table_vals,
175
+ elem_id="arena_leaderboard_dataframe",
176
+ height=800,
177
+ column_widths=[50, 100, 205, 95, 95, 95],
178
+ wrap=True,
179
+ )
180
+
181
  gr.Markdown(pic_markdown)
182
  gr.Markdown("###### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。请自觉合规使用此程序,程序开发者不负有任何责任。</center>")
183