File size: 4,665 Bytes
20d05ae
 
925d97e
 
 
 
 
 
 
 
 
20d05ae
925d97e
 
 
0cb3834
925d97e
 
 
 
 
 
 
eb3ba2e
925d97e
 
 
42cf67e
925d97e
f98d769
925d97e
 
 
 
 
 
 
 
eb3ba2e
925d97e
 
 
 
 
613930c
 
 
 
 
 
 
80a2de5
 
 
613930c
20d05ae
613930c
 
eb3ba2e
03bff01
13ec671
5e1f660
03bff01
0cb3834
 
03bff01
0cb3834
613930c
0cb3834
 
9031563
 
03bff01
 
 
 
0cb3834
 
 
03bff01
0cb3834
613930c
0cb3834
eb3ba2e
80a2de5
90d557d
 
 
 
 
 
 
 
80a2de5
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
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>
""")

pic_markdown = ("""
<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: 220px;" /></a> </h1>
""")

with gr.Blocks() 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])
                
    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)