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 = ("""

🌊💕🎶 滔滔AI,AI歌手模型开源社区

🌟 完全开源、完全免费、共建共享!全网AI歌手任您选择!

""") with gr.Blocks() as app: gr.Markdown(title_markdown) with gr.Tab("模型搜索及上传"): gr.HTML("

1. 搜索AI歌手模型

") 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("

2. 上传AI歌手模型至社区 (上传完成后您立即可以搜索到您上传的模型)

") 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)