Spaces:
Running
Running
import gradio as gr | |
import os | |
from constants import VOICE_METHODS, BARK_VOICES, EDGE_VOICES | |
import platform | |
from models.model import * | |
from tts.conversion import COQUI_LANGUAGES | |
import pytube | |
import os | |
import traceback | |
from pydub import AudioSegment | |
# from audio_enhance.functions import audio_enhance | |
import ast | |
import argparse | |
import glob | |
import pickle | |
import numpy as np | |
import pandas as pd | |
block_css = """ | |
#notice_markdown { | |
font-size: 104% | |
} | |
#notice_markdown th { | |
display: none; | |
} | |
#notice_markdown td { | |
padding-top: 6px; | |
padding-bottom: 6px; | |
} | |
#leaderboard_markdown { | |
font-size: 104% | |
} | |
#leaderboard_markdown td { | |
padding-top: 6px; | |
padding-bottom: 6px; | |
} | |
#leaderboard_dataframe td { | |
line-height: 0.1em; | |
} | |
footer { | |
display:none !important | |
} | |
.image-container { | |
display: flex; | |
align-items: center; | |
padding: 1px; | |
} | |
.image-container img { | |
margin: 0 30px; | |
height: 20px; | |
max-height: 100%; | |
width: auto; | |
max-width: 20%; | |
} | |
""" | |
def model_hyperlink(model_name, link): | |
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>' | |
def load_leaderboard_table_csv(filename, add_hyperlink=True): | |
lines = open(filename).readlines() | |
heads = [v.strip() for v in lines[0].split(",")] | |
rows = [] | |
for i in range(1, len(lines)): | |
row = [v.strip() for v in lines[i].split(",")] | |
for j in range(len(heads)): | |
item = {} | |
for h, v in zip(heads, row): | |
if h != "AI歌手名/AI Singer" and h != "歌手代表作或介绍链接" and h != "模型zip链接/Link to Model Zip File" and h != "模型贡献者/Model Contributor": | |
item[h] = int(v) | |
else: | |
item[h] = v | |
if add_hyperlink: | |
item["AI歌手名/AI Singer"] = model_hyperlink(item["AI歌手名/AI Singer"], item["歌手代表作或介绍链接"]) | |
rows.append(item) | |
return rows | |
def get_arena_table(model_table_df): | |
# sort by rating | |
model_table_df = model_table_df.sort_values(by=["训练素材时长/Duration of Training Dataset(min)"], ascending=False) | |
values = [] | |
for i in range(len(model_table_df)): | |
row = [] | |
model_key = model_table_df.index[i] | |
model_name = model_table_df["AI歌手名/AI Singer"].values[model_key] | |
# rank | |
row.append(i + 1) | |
# model display name | |
row.append(model_name) | |
row.append( | |
model_table_df["模型zip链接/Link to Model Zip File"].values[model_key] | |
) | |
row.append( | |
model_table_df["训练素材时长/Duration of Training Dataset(min)"].values[model_key] | |
) | |
row.append( | |
model_table_df["训练epoch数/Epoch"].values[model_key] | |
) | |
row.append( | |
model_table_df["模型贡献者/Model Contributor"].values[model_key] | |
) | |
values.append(row) | |
return values | |
title_markdown = (""" | |
<h2 align="center"> 🌊💕🎶 滔滔AI,AI歌手模型开源社区 </h2> | |
<h3 align="center"> 🌟 完全开源、完全免费、共建共享!全网AI歌手任您选择! </h3> | |
""") | |
pic_markdown = (""" | |
<h3 align="center"> </h3> | |
<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> | |
""") | |
data = load_leaderboard_table_csv("./OCRBench.csv") | |
model_table_df = pd.DataFrame(data) | |
text_size = gr.themes.sizes.text_lg | |
with gr.Blocks(theme=gr.themes.Base(text_size=text_size), css=block_css) as app: | |
gr.Markdown(title_markdown) | |
with gr.Tab("✨模型搜索及上传"): | |
gr.HTML("<h3>1. 搜索AI歌手模型</h3>") | |
gr.Markdown("##### 点击[此链接](https://docs.google.com/spreadsheets/d/1owfUtQuLW9ReiIwg6U9UkkDmPOTkuNHf0OKQtWu1iaI/edit?gid=1227575351#gid=1227575351),查看全网所有开源AI歌手模型,超9000个模型任您挑选 🥳") | |
search_name = gr.Textbox(placeholder="孙燕姿", label="请填写模型名称进行搜索", show_label=True) | |
# Salida | |
with gr.Row(): | |
sarch_output = gr.Markdown(label="搜索结果") | |
btn_search_model = gr.Button(value="开始搜索吧💖", variant="primary") | |
btn_search_model.click(fn=search_model, inputs=[search_name], outputs=[sarch_output]) | |
gr.HTML("<h3>2. 上传AI歌手模型至社区</h3>") | |
gr.HTML("<h4>上传完成后您立即可以搜索到您上传的模型</h4>") | |
post_name = gr.Textbox(placeholder="滔滔歌姬", label="请填写模型名称", show_label=True) | |
post_model_url = gr.Textbox(placeholder="https://huggingface.co/kevinwang676/RVC-models/resolve/main/talktalkgirl.zip", label="模型链接", info="1.推荐使用Hugging Face存放模型 2.复制Hugging Face模型链接后,需要将链接中的blob四个字母替换成resolve,使模型可以通过链接直接下载", show_label=True) | |
post_creator = gr.Textbox(placeholder="滔滔AI", label="模型贡献者", info="可填写您的昵称或任何有趣的ID", show_label=True) | |
post_version = gr.Dropdown(choices=["RVC v1", "RVC v2"], value="RVC v2", label="RVC模型版本", show_label=True) | |
# Salida | |
with gr.Row(): | |
post_output = gr.Markdown(label="模型上传状态") | |
btn_post_model = gr.Button(value="开始上传吧💕", variant="primary") | |
btn_post_model.click(fn=post_model, inputs=[post_name, post_model_url, post_version, post_creator], outputs=[post_output]) | |
with gr.Tab("🍻滔滔AI精选模型"): | |
arena_table_vals = get_arena_table(model_table_df) | |
md = """ | |
AI翻唱🎶:您可以在社区中复制您喜欢的AI歌手的“模型zip链接”,之后就可以在“🌟重磅首发 - AI歌手全明星💕”页面中通过粘贴zip链接来使用您喜欢的AI歌手模型啦!\n | |
[手机端📱](https://g-app-center-40055665-0593-xqmmjg6.openxlab.space)查看 滔滔AI精选模型 | |
""" | |
gr.Markdown(md, elem_id="leaderboard_markdown") | |
gr.Dataframe( | |
headers=[ | |
"排序", | |
"AI歌手名/AI Singer", | |
"模型zip链接/Link to Model Zip File", | |
"训练素材时长/Duration of Training Dataset(min)", | |
"训练epoch数/Epoch", | |
"模型贡献者/Model Contributor", | |
], | |
datatype=[ | |
"str", | |
"markdown", | |
"str", | |
"number", | |
"number", | |
"str", | |
], | |
value=arena_table_vals, | |
elem_id="arena_leaderboard_dataframe", | |
height=800, | |
column_widths=[50, 100, 205, 95, 95, 95], | |
wrap=True, | |
) | |
gr.Markdown(pic_markdown) | |
gr.Markdown("###### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。请自觉合规使用此程序,程序开发者不负有任何责任。</center>") | |
gr.HTML(''' | |
<div class="footer"> | |
<p>🌊🏞️🎶 - 江水东流急,滔滔无尽声。 明·顾璘 | |
</p> | |
</div> | |
''') | |
app.queue(max_size=40, api_open=False) | |
app.launch(max_threads=400, show_error=True) |