Spaces:
Running
on
Zero
Running
on
Zero
File size: 5,416 Bytes
20d05ae 925d97e 20d05ae 925d97e 0cb3834 925d97e eb3ba2e 925d97e 42cf67e 925d97e f98d769 925d97e eb3ba2e 925d97e 613930c 20d05ae 613930c eb3ba2e 03bff01 13ec671 03bff01 0cb3834 03bff01 0cb3834 613930c 0cb3834 13ec671 03bff01 0cb3834 03bff01 0cb3834 613930c 0cb3834 eb3ba2e 20d05ae eb927b7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
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
def convert_yt_to_wav(url):
if not url:
return "Primero introduce el enlace del video", None
try:
print(f"Convirtiendo video {url}...")
# Descargar el video utilizando pytube
video = pytube.YouTube(url)
stream = video.streams.filter(only_audio=True).first()
video_output_folder = os.path.join(f"yt_videos") # Ruta de destino de la carpeta
audio_output_folder = 'audios'
print("Downloading video")
video_file_path = stream.download(output_path=video_output_folder)
print(video_file_path)
file_name = os.path.basename(video_file_path)
audio_file_path = os.path.join(audio_output_folder, file_name.replace('.mp4','.wav'))
# convert mp4 to wav
print("Converting to wav")
sound = AudioSegment.from_file(video_file_path,format="mp4")
sound.export(audio_file_path, format="wav")
if os.path.exists(video_file_path):
os.remove(video_file_path)
return "Success", audio_file_path
except ConnectionResetError as cre:
return "Se ha perdido la conexión, recarga o reintentalo nuevamente más tarde.", None
except Exception as e:
return str(e), None
title_markdown = ("""
<h1 align="center"> 🌊💕🎶 滔滔AI,AI歌手模型开源社区 </h2>
<h2 align="center"> 🌟 完全开源、完全免费、共建共享!全网AI歌手任您选择! </h2>
""")
with gr.Blocks() as app:
gr.Markdown(title_markdown)
with gr.Tab("模型搜索及上传"):
gr.HTML("<h3>1. 搜索AI歌手模型</h3>")
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>")
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.Column():
# model_voice_path07 = gr.Dropdown(
# label=i18n("RVC Model:"),
# choices=sorted(names),
# value=default_weight,
# )
# best_match_index_path1, _ = match_index(
# model_voice_path07.value
# )
# file_index2_07 = gr.Dropdown(
# label=i18n("Select the .index file:"),
# choices=get_indexes(),
# value=best_match_index_path1,
# interactive=True,
# allow_custom_value=True,
# )
# with gr.Row():
# refresh_button_ = gr.Button(i18n("Refresh"), variant="primary")
# refresh_button_.click(
# fn=change_choices2,
# inputs=[],
# outputs=[model_voice_path07, file_index2_07],
# )
# with gr.Row():
# original_ttsvoice = gr.Audio(label=i18n("Audio TTS:"))
# ttsvoice = gr.Audio(label=i18n("Audio RVC:"))
# with gr.Row():
# button_test = gr.Button(i18n("Convert"), variant="primary")
# button_test.click(
# tts.use_tts,
# inputs=[
# text_test,
# tts_test,
# model_voice_path07,
# file_index2_07,
# # transpose_test,
# vc_transform0,
# f0method8,
# index_rate1,
# crepe_hop_length,
# f0_autotune,
# ttsmethod_test,
# ],
# outputs=[ttsvoice, original_ttsvoice],
# )
app.queue(max_size=40, api_open=False)
app.launch(max_threads=400, show_error=True) |