Spaces:
Runtime error
Runtime error
xJuuzouYTx commited on
Commit ·
eb3ba2e
1
Parent(s): 42cf67e
[ADD] edge tts
Browse filesFiles changed (4)
- app.py+87-1
- requirements.txt+5-2
- tts/constants.pyAdded+438
- tts/conversion.pyAdded+138
5 unmodified lines6789101155 unmodified lines67686970717243 unmodified lines11611711811912012112 unmodified lines13413513613713813916 unmodified lines1561571581591605 unmodified linesfrom utils.model import model_downloader, get_modelimport requestsimport jsonapi_url = "https://rvc-models-api.onrender.com/uploadfile/"55 unmodified lineselse:returndef post_model(name, model_url, version, creator):modelname = model_downloader(model_url, zips_folder, unzips_folder)model_files = get_model(unzips_folder, modelname)43 unmodified linesresult.append(f"**Nombre del modelo: {model_name}**</br>{model_url}</br>")yield "</br>".join(result)cont += 1with gr.Blocks() as app:gr.HTML("<h1> Simple RVC Inference - by Juuxn 💻 </h1>")12 unmodified linesbtn = gr.Button(value="Convertir")btn.click(infer, inputs=[model_url, f0_method, audio_path], outputs=[vc_output1, vc_output2])with gr.Tab("Recursos"):gr.HTML("<h4>Buscar modelos</h4>")search_name = gr.Textbox(placeholder="Billie Eillish (RVC v2 - 100 epoch)", label="Nombre", show_label=True)16 unmodified linesbtn_post_model = gr.Button(value="Publicar")btn_post_model.click(fn=post_model, inputs=[post_name, post_model_url, post_version, post_creator], outputs=[post_output])app.queue(concurrency_count=511, max_size=1022).launch(share=True)5 unmodified lines67891011121355 unmodified lines6970717273747543 unmodified lines11912012112212312412512612712812913012 unmodified lines14314414514614714814915015115215315415515615715815916016116216316416516616716816917017117216 unmodified lines1891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452465 unmodified linesfrom utils.model import model_downloader, get_modelimport requestsimport jsonfrom tts.constants import VOICE_METHODS, BARK_VOICES, EDGE_VOICESfrom tts.conversion import tts_inferapi_url = "https://rvc-models-api.onrender.com/uploadfile/"55 unmodified lineselse:returndef post_model(name, model_url, version, creator):modelname = model_downloader(model_url, zips_folder, unzips_folder)model_files = get_model(unzips_folder, modelname)43 unmodified linesresult.append(f"**Nombre del modelo: {model_name}**</br>{model_url}</br>")yield "</br>".join(result)cont += 1def update_tts_methods_voice(select_value):if select_value == "Edge-tts":return gr.update(choices=EDGE_VOICES)elif select_value == "Bark-tts":return gr.update(choices=BARK_VOICES)with gr.Blocks() as app:gr.HTML("<h1> Simple RVC Inference - by Juuxn 💻 </h1>")12 unmodified linesbtn = gr.Button(value="Convertir")btn.click(infer, inputs=[model_url, f0_method, audio_path], outputs=[vc_output1, vc_output2])with gr.TabItem("TTS"):with gr.Row():tts_text = gr.Textbox(label="Texto:",placeholder="Texto que deseas convertir a voz...",lines=6,)with gr.Column():with gr.Row():tts_model_url = gr.Textbox(placeholder="https://huggingface.co/AIVER-SE/BillieEilish/resolve/main/BillieEilish.zip", label="Url del modelo RVC", show_label=True)with gr.Column():tts_method = gr.Dropdown(choices=VOICE_METHODS, value="Edge-tts", label="Método TTS:", visible=False)tts_model = gr.Dropdown(choices=EDGE_VOICES, label="Modelo TTS:", visible=True, interactive=True)tts_method.change(fn=update_tts_methods_voice, inputs=[tts_method], outputs=[tts_model])with gr.Row():tts_vc_output1 = gr.Textbox(label="Salida")tts_vc_output2 = gr.Audio(label="Audio de salida")tts_btn = gr.Button(value="Convertir")tts_btn.click(fn=tts_infer, inputs=[tts_text, tts_model_url, tts_method, tts_model], outputs=[tts_vc_output1, tts_vc_output2])with gr.Tab("Recursos"):gr.HTML("<h4>Buscar modelos</h4>")search_name = gr.Textbox(placeholder="Billie Eillish (RVC v2 - 100 epoch)", label="Nombre", show_label=True)16 unmodified linesbtn_post_model = gr.Button(value="Publicar")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(concurrency_count=511, max_size=1022).launch()#share=True
12340 unmodified lines44454647484950115 unmodified lines166167168169170absl-py==1.4.0aiofiles==23.1.0aiohttp==3.8.340 unmodified linesfuture==0.18.2google-auth==2.16.2google-auth-oauthlib==1.0.0gradio==3.34.0gradio_client==0.2.10grpcio==1.51.3gspread==5.10.0115 unmodified lineszipp==3.15.0firebasefirebase_admingdownvalidators123440 unmodified lines45464748495051115 unmodified lines167168169170171172173git+git@github.com:huggingface/transformers.git@main#egg=transformersabsl-py==1.4.0aiofiles==23.1.0aiohttp==3.8.340 unmodified linesfuture==0.18.2google-auth==2.16.2google-auth-oauthlib==1.0.0gradiogradio_client==0.2.10grpcio==1.51.3gspread==5.10.0115 unmodified lineszipp==3.15.0firebasefirebase_adminnltkgdownvalidatorsgit+https://github.com/suno-ai/bark.git
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438VOICE_METHODS = ["Edge-tts", "Bark-tts"]
BARK_VOICES = [ "v2/en_speaker_0-Male", "v2/en_speaker_1-Male", "v2/en_speaker_2-Male", "v2/en_speaker_3-Male", "v2/en_speaker_4-Male", "v2/en_speaker_5-Male", "v2/en_speaker_6-Male", "v2/en_speaker_7-Male", "v2/en_speaker_8-Male", "v2/en_speaker_9-Female", "v2/zh_speaker_0-Male", "v2/zh_speaker_1-Male", "v2/zh_speaker_2-Male", "v2/zh_speaker_3-Male", "v2/zh_speaker_4-Female", "v2/zh_speaker_5-Male", "v2/zh_speaker_6-Female", "v2/zh_speaker_7-Female", "v2/zh_speaker_8-Male", "v2/zh_speaker_9-Female", "v2/fr_speaker_0-Male", "v2/fr_speaker_1-Female", "v2/fr_speaker_2-Female", "v2/fr_speaker_3-Male", "v2/fr_speaker_4-Male", "v2/fr_speaker_5-Female", "v2/fr_speaker_6-Male", "v2/fr_speaker_7-Male", "v2/fr_speaker_8-Male", "v2/fr_speaker_9-Male", "v2/de_speaker_0-Male", "v2/de_speaker_1-Male", "v2/de_speaker_2-Male", "v2/de_speaker_3-Female", "v2/de_speaker_4-Male", "v2/de_speaker_5-Male", "v2/de_speaker_6-Male", "v2/de_speaker_7-Male", "v2/de_speaker_8-Female", "v2/de_speaker_9-Male", "v2/hi_speaker_0-Female", "v2/hi_speaker_1-Female", "v2/hi_speaker_2-Male", "v2/hi_speaker_3-Female", "v2/hi_speaker_4-Female", "v2/hi_speaker_5-Male", "v2/hi_speaker_6-Male", "v2/hi_speaker_7-Male", "v2/hi_speaker_8-Male", "v2/hi_speaker_9-Female", "v2/it_speaker_0-Male", "v2/it_speaker_1-Male", "v2/it_speaker_2-Female", "v2/it_speaker_3-Male", "v2/it_speaker_4-Male", "v2/it_speaker_5-Male", "v2/it_speaker_6-Male", "v2/it_speaker_7-Female", "v2/it_speaker_8-Male", "v2/it_speaker_9-Female", "v2/ja_speaker_0-Female", "v2/ja_speaker_1-Female", "v2/ja_speaker_2-Male", "v2/ja_speaker_3-Female", "v2/ja_speaker_4-Female", "v2/ja_speaker_5-Female", "v2/ja_speaker_6-Male", "v2/ja_speaker_7-Female", "v2/ja_speaker_8-Female", "v2/ja_speaker_9-Female", "v2/ko_speaker_0-Female", "v2/ko_speaker_1-Male", "v2/ko_speaker_2-Male", "v2/ko_speaker_3-Male", "v2/ko_speaker_4-Male", "v2/ko_speaker_5-Male", "v2/ko_speaker_6-Male", "v2/ko_speaker_7-Male", "v2/ko_speaker_8-Male", "v2/ko_speaker_9-Male", "v2/pl_speaker_0-Male", "v2/pl_speaker_1-Male", "v2/pl_speaker_2-Male", "v2/pl_speaker_3-Male", "v2/pl_speaker_4-Female", "v2/pl_speaker_5-Male", "v2/pl_speaker_6-Female", "v2/pl_speaker_7-Male", "v2/pl_speaker_8-Male", "v2/pl_speaker_9-Female", "v2/pt_speaker_0-Male", "v2/pt_speaker_1-Male", "v2/pt_speaker_2-Male", "v2/pt_speaker_3-Male", "v2/pt_speaker_4-Male", "v2/pt_speaker_5-Male", "v2/pt_speaker_6-Male", "v2/pt_speaker_7-Male", "v2/pt_speaker_8-Male", "v2/pt_speaker_9-Male", "v2/ru_speaker_0-Male", "v2/ru_speaker_1-Male", "v2/ru_speaker_2-Male", "v2/ru_speaker_3-Male", "v2/ru_speaker_4-Male", "v2/ru_speaker_5-Female", "v2/ru_speaker_6-Female", "v2/ru_speaker_7-Male", "v2/ru_speaker_8-Male", "v2/ru_speaker_9-Female", "v2/es_speaker_0-Male", "v2/es_speaker_1-Male", "v2/es_speaker_2-Male", "v2/es_speaker_3-Male", "v2/es_speaker_4-Male", "v2/es_speaker_5-Male", "v2/es_speaker_6-Male", "v2/es_speaker_7-Male", "v2/es_speaker_8-Female", "v2/es_speaker_9-Female", "v2/tr_speaker_0-Male", "v2/tr_speaker_1-Male", "v2/tr_speaker_2-Male", "v2/tr_speaker_3-Male", "v2/tr_speaker_4-Female", "v2/tr_speaker_5-Female", "v2/tr_speaker_6-Male", "v2/tr_speaker_7-Male", "v2/tr_speaker_8-Male", "v2/tr_speaker_9-Male",]
EDGE_VOICES = [ "af-ZA-AdriNeural-Female", "af-ZA-WillemNeural-Male", "sq-AL-AnilaNeural-Female", "sq-AL-IlirNeural-Male", "am-ET-AmehaNeural-Male", "am-ET-MekdesNeural-Female", "ar-DZ-AminaNeural-Female", "ar-DZ-IsmaelNeural-Male", "ar-BH-AliNeural-Male", "ar-BH-LailaNeural-Female", "ar-EG-SalmaNeural-Female", "ar-EG-ShakirNeural-Male", "ar-IQ-BasselNeural-Male", "ar-IQ-RanaNeural-Female", "ar-JO-SanaNeural-Female", "ar-JO-TaimNeural-Male", "ar-KW-FahedNeural-Male", "ar-KW-NouraNeural-Female", "ar-LB-LaylaNeural-Female", "ar-LB-RamiNeural-Male", "ar-LY-ImanNeural-Female", "ar-LY-OmarNeural-Male", "ar-MA-JamalNeural-Male", "ar-MA-MounaNeural-Female", "ar-OM-AbdullahNeural-Male", "ar-OM-AyshaNeural-Female", "ar-QA-AmalNeural-Female", "ar-QA-MoazNeural-Male", "ar-SA-HamedNeural-Male", "ar-SA-ZariyahNeural-Female", "ar-SY-AmanyNeural-Female", "ar-SY-LaithNeural-Male", "ar-TN-HediNeural-Male", "ar-TN-ReemNeural-Female", "ar-AE-FatimaNeural-Female", "ar-AE-HamdanNeural-Male", "ar-YE-MaryamNeural-Female", "ar-YE-SalehNeural-Male", "az-AZ-BabekNeural-Male", "az-AZ-BanuNeural-Female", "bn-BD-NabanitaNeural-Female", "bn-BD-PradeepNeural-Male", "bn-IN-BashkarNeural-Male", "bn-IN-TanishaaNeural-Female", "bs-BA-GoranNeural-Male", "bs-BA-VesnaNeural-Female", "bg-BG-BorislavNeural-Male", "bg-BG-KalinaNeural-Female", "my-MM-NilarNeural-Female", "my-MM-ThihaNeural-Male", "ca-ES-EnricNeural-Male", "ca-ES-JoanaNeural-Female", "zh-HK-HiuGaaiNeural-Female", "zh-HK-HiuMaanNeural-Female", "zh-HK-WanLungNeural-Male", "zh-CN-XiaoxiaoNeural-Female", "zh-CN-XiaoyiNeural-Female", "zh-CN-YunjianNeural-Male", "zh-CN-YunxiNeural-Male", "zh-CN-YunxiaNeural-Male", "zh-CN-YunyangNeural-Male", "zh-CN-liaoning-XiaobeiNeural-Female", "zh-TW-HsiaoChenNeural-Female", "zh-TW-YunJheNeural-Male", "zh-TW-HsiaoYuNeural-Female", "zh-CN-shaanxi-XiaoniNeural-Female", "hr-HR-GabrijelaNeural-Female", "hr-HR-SreckoNeural-Male", "cs-CZ-AntoninNeural-Male", "cs-CZ-VlastaNeural-Female", "da-DK-ChristelNeural-Female", "da-DK-JeppeNeural-Male", "nl-BE-ArnaudNeural-Male", "nl-BE-DenaNeural-Female", "nl-NL-ColetteNeural-Female", "nl-NL-FennaNeural-Female", "nl-NL-MaartenNeural-Male", "en-AU-NatashaNeural-Female", "en-AU-WilliamNeural-Male", "en-CA-ClaraNeural-Female", "en-CA-LiamNeural-Male", "en-HK-SamNeural-Male", "en-HK-YanNeural-Female", "en-IN-NeerjaExpressiveNeural-Female", "en-IN-NeerjaNeural-Female", "en-IN-PrabhatNeural-Male", "en-IE-ConnorNeural-Male", "en-IE-EmilyNeural-Female", "en-KE-AsiliaNeural-Female", "en-KE-ChilembaNeural-Male", "en-NZ-MitchellNeural-Male", "en-NZ-MollyNeural-Female", "en-NG-AbeoNeural-Male", "en-NG-EzinneNeural-Female", "en-PH-JamesNeural-Male", "en-PH-RosaNeural-Female", "en-SG-LunaNeural-Female", "en-SG-WayneNeural-Male", "en-ZA-LeahNeural-Female", "en-ZA-LukeNeural-Male", "en-TZ-ElimuNeural-Male", "en-TZ-ImaniNeural-Female", "en-GB-LibbyNeural-Female", "en-GB-MaisieNeural-Female", "en-GB-RyanNeural-Male", "en-GB-SoniaNeural-Female", "en-GB-ThomasNeural-Male", "en-US-AriaNeural-Female", "en-US-AnaNeural-Female", "en-US-ChristopherNeural-Male", "en-US-EricNeural-Male", "en-US-GuyNeural-Male", "en-US-JennyNeural-Female", "en-US-MichelleNeural-Female", "en-US-RogerNeural-Male", "en-US-SteffanNeural-Male", "et-EE-AnuNeural-Female", "et-EE-KertNeural-Male", "fil-PH-AngeloNeural-Male", "fil-PH-BlessicaNeural-Female", "fi-FI-HarriNeural-Male", "fi-FI-NooraNeural-Female", "fr-BE-CharlineNeural-Female", "fr-BE-GerardNeural-Male", "fr-CA-AntoineNeural-Male", "fr-CA-JeanNeural-Male", "fr-CA-SylvieNeural-Female", "fr-FR-DeniseNeural-Female", "fr-FR-EloiseNeural-Female", "fr-FR-HenriNeural-Male", "fr-CH-ArianeNeural-Female", "fr-CH-FabriceNeural-Male", "gl-ES-RoiNeural-Male", "gl-ES-SabelaNeural-Female", "ka-GE-EkaNeural-Female", "ka-GE-GiorgiNeural-Male", "de-AT-IngridNeural-Female", "de-AT-JonasNeural-Male", "de-DE-AmalaNeural-Female", "de-DE-ConradNeural-Male", "de-DE-KatjaNeural-Female", "de-DE-KillianNeural-Male", "de-CH-JanNeural-Male", "de-CH-LeniNeural-Female", "el-GR-AthinaNeural-Female", "el-GR-NestorasNeural-Male", "gu-IN-DhwaniNeural-Female", "gu-IN-NiranjanNeural-Male", "he-IL-AvriNeural-Male", "he-IL-HilaNeural-Female", "hi-IN-MadhurNeural-Male", "hi-IN-SwaraNeural-Female", "hu-HU-NoemiNeural-Female", "hu-HU-TamasNeural-Male", "is-IS-GudrunNeural-Female", "is-IS-GunnarNeural-Male", "id-ID-ArdiNeural-Male", "id-ID-GadisNeural-Female", "ga-IE-ColmNeural-Male", "ga-IE-OrlaNeural-Female", "it-IT-DiegoNeural-Male", "it-IT-ElsaNeural-Female", "it-IT-IsabellaNeural-Female", "ja-JP-KeitaNeural-Male", "ja-JP-NanamiNeural-Female", "jv-ID-DimasNeural-Male", "jv-ID-SitiNeural-Female", "kn-IN-GaganNeural-Male", "kn-IN-SapnaNeural-Female", "kk-KZ-AigulNeural-Female", "kk-KZ-DauletNeural-Male", "km-KH-PisethNeural-Male", "km-KH-SreymomNeural-Female", "ko-KR-InJoonNeural-Male", "ko-KR-SunHiNeural-Female", "lo-LA-ChanthavongNeural-Male", "lo-LA-KeomanyNeural-Female", "lv-LV-EveritaNeural-Female", "lv-LV-NilsNeural-Male", "lt-LT-LeonasNeural-Male", "lt-LT-OnaNeural-Female", "mk-MK-AleksandarNeural-Male", "mk-MK-MarijaNeural-Female", "ms-MY-OsmanNeural-Male", "ms-MY-YasminNeural-Female", "ml-IN-MidhunNeural-Male", "ml-IN-SobhanaNeural-Female", "mt-MT-GraceNeural-Female", "mt-MT-JosephNeural-Male", "mr-IN-AarohiNeural-Female", "mr-IN-ManoharNeural-Male", "mn-MN-BataaNeural-Male", "mn-MN-YesuiNeural-Female", "ne-NP-HemkalaNeural-Female", "ne-NP-SagarNeural-Male", "nb-NO-FinnNeural-Male", "nb-NO-PernilleNeural-Female", "ps-AF-GulNawazNeural-Male", "ps-AF-LatifaNeural-Female", "fa-IR-DilaraNeural-Female", "fa-IR-FaridNeural-Male", "pl-PL-MarekNeural-Male", "pl-PL-ZofiaNeural-Female", "pt-BR-AntonioNeural-Male", "pt-BR-FranciscaNeural-Female", "pt-PT-DuarteNeural-Male", "pt-PT-RaquelNeural-Female", "ro-RO-AlinaNeural-Female", "ro-RO-EmilNeural-Male", "ru-RU-DmitryNeural-Male", "ru-RU-SvetlanaNeural-Female", "sr-RS-NicholasNeural-Male", "sr-RS-SophieNeural-Female", "si-LK-SameeraNeural-Male", "si-LK-ThiliniNeural-Female", "sk-SK-LukasNeural-Male", "sk-SK-ViktoriaNeural-Female", "sl-SI-PetraNeural-Female", "sl-SI-RokNeural-Male", "so-SO-MuuseNeural-Male", "so-SO-UbaxNeural-Female", "es-AR-ElenaNeural-Female", "es-AR-TomasNeural-Male", "es-BO-MarceloNeural-Male", "es-BO-SofiaNeural-Female", "es-CL-CatalinaNeural-Female", "es-CL-LorenzoNeural-Male", "es-CO-GonzaloNeural-Male", "es-CO-SalomeNeural-Female", "es-CR-JuanNeural-Male", "es-CR-MariaNeural-Female", "es-CU-BelkysNeural-Female", "es-CU-ManuelNeural-Male", "es-DO-EmilioNeural-Male", "es-DO-RamonaNeural-Female", "es-EC-AndreaNeural-Female", "es-EC-LuisNeural-Male", "es-SV-LorenaNeural-Female", "es-SV-RodrigoNeural-Male", "es-GQ-JavierNeural-Male", "es-GQ-TeresaNeural-Female", "es-GT-AndresNeural-Male", "es-GT-MartaNeural-Female", "es-HN-CarlosNeural-Male", "es-HN-KarlaNeural-Female", "es-MX-DaliaNeural-Female", "es-MX-JorgeNeural-Male", "es-NI-FedericoNeural-Male", "es-NI-YolandaNeural-Female", "es-PA-MargaritaNeural-Female", "es-PA-RobertoNeural-Male", "es-PY-MarioNeural-Male", "es-PY-TaniaNeural-Female", "es-PE-AlexNeural-Male", "es-PE-CamilaNeural-Female", "es-PR-KarinaNeural-Female", "es-PR-VictorNeural-Male", "es-ES-AlvaroNeural-Male", "es-ES-ElviraNeural-Female", "es-US-AlonsoNeural-Male", "es-US-PalomaNeural-Female", "es-UY-MateoNeural-Male", "es-UY-ValentinaNeural-Female", "es-VE-PaolaNeural-Female", "es-VE-SebastianNeural-Male", "su-ID-JajangNeural-Male", "su-ID-TutiNeural-Female", "sw-KE-RafikiNeural-Male", "sw-KE-ZuriNeural-Female", "sw-TZ-DaudiNeural-Male", "sw-TZ-RehemaNeural-Female", "sv-SE-MattiasNeural-Male", "sv-SE-SofieNeural-Female", "ta-IN-PallaviNeural-Female", "ta-IN-ValluvarNeural-Male", "ta-MY-KaniNeural-Female", "ta-MY-SuryaNeural-Male", "ta-SG-AnbuNeural-Male", "ta-SG-VenbaNeural-Female", "ta-LK-KumarNeural-Male", "ta-LK-SaranyaNeural-Female", "te-IN-MohanNeural-Male", "te-IN-ShrutiNeural-Female", "th-TH-NiwatNeural-Male", "th-TH-PremwadeeNeural-Female", "tr-TR-AhmetNeural-Male", "tr-TR-EmelNeural-Female", "uk-UA-OstapNeural-Male", "uk-UA-PolinaNeural-Female", "ur-IN-GulNeural-Female", "ur-IN-SalmanNeural-Male", "ur-PK-AsadNeural-Male", "ur-PK-UzmaNeural-Female", "uz-UZ-MadinaNeural-Female", "uz-UZ-SardorNeural-Male", "vi-VN-HoaiMyNeural-Female", "vi-VN-NamMinhNeural-Male", "cy-GB-AledNeural-Male", "cy-GB-NiaNeural-Female", "zu-ZA-ThandoNeural-Female", "zu-ZA-ThembaNeural-Male",]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138import osimport uuidimport numpy as npimport torchimport soundfile as sffrom gtts import gTTSimport edge_ttsfrom inference import Inferenceimport asyncio#git+https://github.com/suno-ai/bark.git# from transformers import AutoProcessor, BarkModel# import nltk# from nltk.tokenize import sent_tokenize# from bark import SAMPLE_RATE
# now_dir = os.getcwd()
def cast_to_device(tensor, device): try: return tensor.to(device) except Exception as e: print(e) return tensor
# Buscar la forma de evitar descargar el archivo de 4gb cada vez que crea una instancia# def _bark_conversion_(text, voice_preset):# os.makedirs(os.path.join(now_dir, "tts"), exist_ok=True)
# device = "cuda:0" if torch.cuda.is_available() else "cpu"# dtype = torch.float32 if "cpu" in device else torch.float16# bark_processor = AutoProcessor.from_pretrained(# "suno/bark",# cache_dir=os.path.join(now_dir, "tts", "suno/bark"),# torch_dtype=dtype,# )# bark_model = BarkModel.from_pretrained(# "suno/bark",# cache_dir=os.path.join(now_dir, "tts", "suno/bark"),# torch_dtype=dtype,# ).to(device)# # bark_model.enable_cpu_offload()# inputs = bark_processor(text=[text], return_tensors="pt", voice_preset=voice_preset)# tensor_dict = {# k: cast_to_device(v, device) if hasattr(v, "to") else v# for k, v in inputs.items()# }# speech_values = bark_model.generate(**tensor_dict, do_sample=True)# sampling_rate = bark_model.generation_config.sample_rate# speech = speech_values.cpu().numpy().squeeze()# return speech, sampling_rate
def tts_infer(tts_text, model_url, tts_method, tts_model): print("*****************") print(tts_text) print(model_url) if not tts_text: return 'Primero escribe el texto que quieres convertir.', None if not tts_model: return 'Selecciona un modelo TTS antes de convertir.', None if not model_url: return 'Escribe la url de modelo que quieres usar antes de convertir.', None f0_method = "harvest" output_folder = "audios" os.makedirs(output_folder, exist_ok=True) converted_tts_filename = os.path.join(output_folder, f"tts_out_{uuid.uuid4()}.wav") success = False
if len(tts_text) > 60: tts_text = tts_text[:60] print("DEMO; limit to 60 characters")
language = tts_model[:2] if tts_method == "Edge-tts": try: asyncio.run( edge_tts.Communicate( tts_text, "-".join(tts_model.split("-")[:-1]) ).save(converted_tts_filename) ) success = True except Exception as e: print("ERROR", e) try: tts = gTTS(tts_text, lang=language) tts.save(converted_tts_filename) print( f"No audio was received. Please change the tts voice for {tts_model}. USING gTTS." ) success = True except: tts = gTTS("a", lang=language) tts.save(converted_tts_filename) print("Error: Audio will be replaced.") success = False # elif tts_method == "Bark-tts": # try: # script = tts_text.replace("\n", " ").strip() # sentences = sent_tokenize(script) # silence = np.zeros(int(0.25 * SAMPLE_RATE)) # pieces = [] # for sentence in sentences: # audio_array, _ = _bark_conversion_(sentence, tts_model.split("-")[0]) # pieces += [audio_array, silence.copy()]
# sf.write( # file=converted_tts_filename, samplerate=SAMPLE_RATE, data=np.concatenate(pieces) # ) # except Exception as e: # print(f"{e}") # return None, None if success: inference = Inference( model_name=model_url, f0_method=f0_method, source_audio_path=converted_tts_filename, output_file_name=os.path.join("./audio-outputs", os.path.basename(converted_tts_filename)), ) output = inference.run() if os.path.exists(converted_tts_filename): os.remove(converted_tts_filename) if os.path.exists(os.path.join("weights", inference.model_name)): os.remove(os.path.join("weights", inference.model_name)) if 'success' in output and output['success']: return output, output['file'] else: return output, None else: return "Ocurrió un error durante la conversión", None app.py+87-1
requirements.txt+5-2
tts/constants.pyAdded+438
tts/conversion.pyAdded+138