Update app.py
Browse files1471 unmodified lines14721473147414751476147714781479148014815 unmodified lines1487148814891490149114921493149414951496149710 unmodified lines15081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154610 unmodified lines15571558155915601561156215631564156515661567156815691570157115721573157415753 unmodified lines157915801581158215831584158515861587158815891590159115921593159410 unmodified lines1605160616071608160916101611161216131614161516161617161816191620162116221623112 unmodified lines1736173717381739174017411742174317441745174617471748174917501471 unmodified lineswith gr.Blocks(theme=gr.themes.Base(), title='Mangio-RVC-Web 💻') as app:with gr.Tabs():with gr.TabItem("Интерфейс"):gr.HTML("<h1> RVC V2 Huggingface Version </h1>")gr.HTML("<h10> Huggingface version выполненная [Clebersla](https://huggingface.co/spaces/Clebersla/RVC_V2_Huggingface_Version) </h10>")gr.HTML("<h4> Если вы хотите использовать это помещение в частном порядке, я рекомендую продублировать его. </h4>")# Inference Preset Row# with gr.Row():5 unmodified lines# Other RVC stuffwith gr.Row():sid0 = gr.Dropdown(label="1.Выберите свою модель.", choices=sorted(names), value=check_for_name())refresh_button = gr.Button("Обновить", variant="primary")if check_for_name() != '':get_vc(sorted(names)[0])vc_transform0 = gr.Number(label="Дополнительно: Здесь можно изменить высоту тона или оставить ее равной 0.", value=0)#clean_button = gr.Button(i18n("卸载音色省显存"), variant="primary")spk_item = gr.Slider(minimum=0,10 unmodified linesinputs=[sid0],outputs=[spk_item],)but0 = gr.Button("Конвертировать", variant="primary")with gr.Row():with gr.Column():with gr.Row():dropbox = gr.File(label='Отправьте аудиозапись сюда и нажмите кнопку "Перезагрузка".')with gr.Row():record_button=gr.Audio(source="microphone", label="Запись звука с микрофона.", type="filepath")with gr.Row():input_audio0 = gr.Dropdown(label="2.Выберите аудиозапись.",value="./audios/someguy.mp3",choices=audio_files)dropbox.upload(fn=save_to_wav2, inputs=[dropbox], outputs=[input_audio0])dropbox.upload(fn=change_choices2, inputs=[], outputs=[input_audio0])refresh_button2 = gr.Button("Обновить", variant="primary", size='sm')record_button.change(fn=save_to_wav, inputs=[record_button], outputs=[input_audio0])record_button.change(fn=change_choices2, inputs=[], outputs=[input_audio0])with gr.Row():with gr.Accordion('Текст в речь', open=False):with gr.Column():lang = gr.Radio(label='Китайский и японский языки в настоящее время не работают с ElevenLabs.',choices=['en','es','fr','pt','zh-CN','de','hi','ja','ua'], value='en')api_box = gr.Textbox(label="Введите свой API-ключ для ElevenLabs или оставьте пустым, чтобы использовать GoogleTTS", value='')elevenid=gr.Dropdown(label="Голос:", choices=eleven_voices)with gr.Column():tfs = gr.Textbox(label="Введите свой текст", interactive=True, value="This is a test.")tts_button = gr.Button(value="Генерировать")tts_button.click(fn=elevenTTS, inputs=[api_box,tfs, elevenid, lang], outputs=[record_button, input_audio0])with gr.Column():with gr.Accordion("Настройки индекса", open=False):file_index1 = gr.Dropdown(label="3. Путь к файлу added.index (если он не был найден автоматически).",choices=get_indexes(),value=get_index(),interactive=True,10 unmodified linesindex_rate1 = gr.Slider(minimum=0,maximum=1,label=i18n("Процентное соотношение поисковых функций (советую ставить на 0)"),value=0.66,interactive=True,)vc_output2 = gr.Audio(label="Выходные аудиоданные (нажмите на три точки в правом углу, чтобы загрузить)",type='filepath',interactive=False,)with gr.Accordion("Дополнительные настройки", open=False):f0method0 = gr.Radio(label='Необязательно: Изменить алгоритм извлечения высоты тона.\Методы извлечения отсортированы от "худшего качества" к "лучшему качеству".\mangio-crepe может быть лучше rmvpe или нет в случаях, когда "гладкость" более важна, но в целом rmvpe является лучшим.',choices=["pm", "dio", "crepe-tiny", "mangio-crepe-tiny", "crepe", "harvest", "mangio-crepe", "rmvpe"], # Fork Feature. Add Crepe-Tinyvalue="rmvpe",interactive=True,3 unmodified linesminimum=1,maximum=512,step=1,label="Mangio-Crepe Hop Length. Более высок��е числа уменьшат вероятность экстремального изменения высоты тона, но более низкие числа увеличат точность. 64-192 - хороший диапазон для экспериментов.",value=120,interactive=True,visible=False)f0method0.change(fn=whethercrepeornah, inputs=[f0method0], outputs=[crepe_hop_length])filter_radius0 = gr.Slider(minimum=0,maximum=7,label=i18n("Если >=3: применить медианную фильтрацию к собранным результатам питча. Значение представляет собой радиус фильтрации и может уменьшить дыхание."),value=3,step=1,interactive=True,10 unmodified linesrms_mix_rate0 = gr.Slider(minimum=0,maximum=1,label=i18n("Используйте огибающую громкости входа для замены или смешивания с огибающей громкости выхода. Чем ближе это соотношение к 1, тем больше используется огибающая выходного сигнала:"),value=0.21,interactive=True,)protect0 = gr.Slider(minimum=0,maximum=0.5,label=i18n("Защита безголосых согласных и звуков дыхания для предотвращения артефактов, таких как разрывы в электронной музыке. Для отключения установите значение 0,5. Уменьшите значение для усиления защиты, но это может снизить точность индексирования:"),value=0.33,step=0.01,interactive=True,)with gr.Accordion("Batch Conversion",open=False):with gr.Row():112 unmodified lines[vc_output3],)but1.click(fn=lambda: easy_uploader.clear())with gr.TabItem("Загрузить модель"):with gr.Row():url=gr.Textbox(label="Введите URL-адрес модели:")with gr.Row():model = gr.Textbox(label="Назовите свою модель:")download_button=gr.Button("Загрузить")with gr.Row():status_bar=gr.Textbox(label="")download_button.click(fn=download_from_url, inputs=[url, model], outputs=[status_bar])def has_two_files_in_pretrained_folder():pretrained_folder = "./pretrained/"1471 unmodified lines14721473147414751476147714781479148014815 unmodified lines1487148814891490149114921493149414951496149710 unmodified lines1508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156010 unmodified lines15711572157315741575157615771578157915801581158215831584158515861587158815893 unmodified lines159315941595159615971598159916001601160216031604160516061607160810 unmodified lines161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708112 unmodified lines1821182218231824182518261827182818291830183118321833183418351836183718381839184018411471 unmodified lineswith gr.Blocks(theme=gr.themes.Base(), title='Mangio-RVC-Web 💻') as app:with gr.Tabs():with gr.TabItem("Inference"):gr.HTML("<h1> RVC V2 Huggingface Version </h1>")gr.HTML("<h10> Huggingface version made by Clebersla </h10>")gr.HTML("<h4> If you want to use this space privately, I recommend you duplicate the space. </h4>")# Inference Preset Row# with gr.Row():5 unmodified lines# Other RVC stuffwith gr.Row():sid0 = gr.Dropdown(label="1.Choose your Model.", choices=sorted(names), value=check_for_name())refresh_button = gr.Button("Refresh", variant="primary")if check_for_name() != '':get_vc(sorted(names)[0])vc_transform0 = gr.Number(label="Optional: You can change the pitch here or leave it at 0.", value=0)#clean_button = gr.Button(i18n("卸载音色省显存"), variant="primary")spk_item = gr.Slider(minimum=0,10 unmodified linesinputs=[sid0],outputs=[spk_item],)but0 = gr.Button("Convert", variant="primary")with gr.Row():with gr.Column():with gr.Row():dropbox = gr.File(label="Drop your audio here & hit the Reload button.")with gr.Row():record_button=gr.Audio(source="microphone", label="OR Record audio.", type="filepath")with gr.Row():input_audio0 = gr.Dropdown(label="2.Choose your audio.",value="./audios/someguy.mp3",choices=audio_files)dropbox.upload(fn=save_to_wav2, inputs=[dropbox], outputs=[input_audio0])dropbox.upload(fn=change_choices2, inputs=[], outputs=[input_audio0])refresh_button2 = gr.Button("Refresh", variant="primary", size='sm')record_button.change(fn=save_to_wav, inputs=[record_button], outputs=[input_audio0])record_button.change(fn=change_choices2, inputs=[], outputs=[input_audio0])with gr.Row():with gr.Accordion('Text To Speech', open=False):with gr.Column():lang = gr.Radio(label='Chinese & Japanese do not work with ElevenLabs currently.',choices=['en','es','fr','pt','zh-CN','de','hi','ja'], value='en')api_box = gr.Textbox(label="Enter your API Key for ElevenLabs, or leave empty to use GoogleTTS", value='')elevenid=gr.Dropdown(label="Voice:", choices=eleven_voices)with gr.Column():tfs = gr.Textbox(label="Input your Text", interactive=True, value="This is a test.")tts_button = gr.Button(value="Speak")tts_button.click(fn=elevenTTS, inputs=[api_box,tfs, elevenid, lang], outputs=[record_button, input_audio0])with gr.Row():with gr.Accordion('Wav2Lip', open=False):with gr.Row():size = gr.Radio(label='Resolution:',choices=['Half','Full'])face = gr.UploadButton("Upload A Character",type='file')faces = gr.Dropdown(label="OR Choose one:", choices=['None','Ben Shapiro','Andrew Tate'])with gr.Row():preview = gr.Textbox(label="Status:",interactive=False)face.upload(fn=success_message,inputs=[face], outputs=[preview, faces])with gr.Row():animation = gr.Video(type='filepath')refresh_button2.click(fn=change_choices2, inputs=[], outputs=[input_audio0, animation])with gr.Row():animate_button = gr.Button('Animate')with gr.Column():with gr.Accordion("Index Settings", open=False):file_index1 = gr.Dropdown(label="3. Path to your added.index file (if it didn't automatically find it.)",choices=get_indexes(),value=get_index(),interactive=True,10 unmodified linesindex_rate1 = gr.Slider(minimum=0,maximum=1,label=i18n("检索特征占比"),value=0.66,interactive=True,)vc_output2 = gr.Audio(label="Output Audio (Click on the Three Dots in the Right Corner to Download)",type='filepath',interactive=False,)animate_button.click(fn=mouth, inputs=[size, face, vc_output2, faces], outputs=[animation, preview])with gr.Accordion("Advanced Settings", open=False):f0method0 = gr.Radio(label="Optional: Change the Pitch Extraction Algorithm.\nExtraction methods are sorted from 'worst quality' to 'best quality'.\nmangio-crepe may or may not be better than rmvpe in cases where 'smoothness' is more important, but rmvpe is the best overall.",choices=["pm", "dio", "crepe-tiny", "mangio-crepe-tiny", "crepe", "harvest", "mangio-crepe", "rmvpe"], # Fork Feature. Add Crepe-Tinyvalue="rmvpe",interactive=True,3 unmodified linesminimum=1,maximum=512,step=1,label="Mangio-Crepe Hop Length. Higher numbers will reduce the chance of extreme pitch changes but lower numbers will increase accuracy. 64-192 is a good range to experiment with.",value=120,interactive=True,visible=False,)f0method0.change(fn=whethercrepeornah, inputs=[f0method0], outputs=[crepe_hop_length])filter_radius0 = gr.Slider(minimum=0,maximum=7,label=i18n(">=3则使用对harvest音高识别的结果使用中值滤波,数值为滤波半径,使用可以削弱哑音"),value=3,step=1,interactive=True,10 unmodified linesrms_mix_rate0 = gr.Slider(minimum=0,maximum=1,label=i18n("输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络"),value=0.21,interactive=True,)protect0 = gr.Slider(minimum=0,maximum=0.5,label=i18n("保护清辅音和呼吸声,防止电音撕裂等artifact,拉满0.5不开启,调低加大保护力度但可能降低索引效果"),value=0.33,step=0.01,interactive=True,)formanting = gr.Checkbox(value=bool(DoFormant),label="[EXPERIMENTAL] Formant shift inference audio",info="Used for male to female and vice-versa conversions",interactive=True,visible=True,)formant_preset = gr.Dropdown(value='',choices=get_fshift_presets(),label="browse presets for formanting",visible=bool(DoFormant),)formant_refresh_button = gr.Button(value='\U0001f504',visible=bool(DoFormant),variant='primary',)#formant_refresh_button = ToolButton( elem_id='1')#create_refresh_button(formant_preset, lambda: {"choices": formant_preset}, "refresh_list_shiftpresets")qfrency = gr.Slider(value=Quefrency,info="Default value is 1.0",label="Quefrency for formant shifting",minimum=0.0,maximum=16.0,step=0.1,visible=bool(DoFormant),interactive=True,)tmbre = gr.Slider(value=Timbre,info="Default value is 1.0",label="Timbre for formant shifting",minimum=0.0,maximum=16.0,step=0.1,visible=bool(DoFormant),interactive=True,)formant_preset.change(fn=preset_apply, inputs=[formant_preset, qfrency, tmbre], outputs=[qfrency, tmbre])frmntbut = gr.Button("Apply", variant="primary", visible=bool(DoFormant))formanting.change(fn=formant_enabled,inputs=[formanting,qfrency,tmbre,frmntbut,formant_preset,formant_refresh_button],outputs=[formanting,qfrency,tmbre,frmntbut,formant_preset,formant_refresh_button])frmntbut.click(fn=formant_apply,inputs=[qfrency, tmbre], outputs=[qfrency, tmbre])formant_refresh_button.click(fn=update_fshift_presets,inputs=[formant_preset, qfrency, tmbre],outputs=[formant_preset, qfrency, tmbre])with gr.Row():vc_output1 = gr.Textbox("")f0_file = gr.File(label=i18n("F0曲线文件, 可选, 一行一个音高, 代替默认F0及升降调"), visible=False)but0.click(vc_single,[spk_item,input_audio0,vc_transform0,f0_file,f0method0,file_index1,# file_index2,# file_big_npy1,index_rate1,filter_radius0,resample_sr0,rms_mix_rate0,protect0,crepe_hop_length],[vc_output1, vc_output2],)with gr.Accordion("Batch Conversion",open=False):with gr.Row():112 unmodified lines[vc_output3],)but1.click(fn=lambda: easy_uploader.clear())with gr.TabItem("Download Model"):with gr.Row():url=gr.Textbox(label="Enter the URL to the Model:")with gr.Row():model = gr.Textbox(label="Name your model:")download_button=gr.Button("Download")with gr.Row():status_bar=gr.Textbox(label="")download_button.click(fn=download_from_url, inputs=[url, model], outputs=[status_bar])with gr.Row():gr.Markdown("""Made with ❤️ by [Alice Oliveira](https://github.com/aliceoq) | Hosted with ❤️ by [Mateus Elias](https://github.com/mateuseap)""")def has_two_files_in_pretrained_folder():pretrained_folder = "./pretrained/"
app.py+125-34