Spaces:
Runtime error
Runtime error
Commit
·
99cadae
1
Parent(s):
a90c06b
Update app_multi.py
Browse files- app_multi.py +179 -112
app_multi.py
CHANGED
@@ -36,6 +36,33 @@ from infer_pack.models import (
|
|
36 |
SynthesizerTrnMs768NSFsid_nono
|
37 |
)
|
38 |
from vc_infer_pipeline import VC
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Reference: https://huggingface.co/spaces/zomehwh/rvc-models/blob/main/app.py#L21 # noqa
|
41 |
in_hf_space = getenv('SYSTEM') == 'spaces'
|
@@ -629,14 +656,91 @@ with app:
|
|
629 |
as_audio_submit.click(fn=audio_separated, inputs=[as_audio_input], outputs=[as_audio_vocals, as_audio_no_vocals, as_audio_message], show_progress=True, queue=True)
|
630 |
|
631 |
with gr.Row():
|
632 |
-
with gr.
|
633 |
-
with gr.
|
634 |
input_audio = as_audio_vocals
|
635 |
vc_convert_btn = gr.Button('进行歌声转换吧!', variant='primary')
|
636 |
full_song = gr.Button("加入歌曲伴奏吧!", variant="primary")
|
637 |
new_song = gr.Audio(label="AI歌手+伴奏", type="filepath")
|
638 |
|
639 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
640 |
tts_input = gr.Textbox(
|
641 |
label='请填写您想要转换的文本(中英皆可)',
|
642 |
lines=3
|
@@ -654,132 +758,95 @@ with app:
|
|
654 |
)
|
655 |
|
656 |
tts_convert_btn = gr.Button('进行AI变声吧', variant='primary')
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
maximum=24,
|
662 |
-
step=1,
|
663 |
-
value=0
|
664 |
-
)
|
665 |
-
f0_method = gr.Radio(
|
666 |
-
label='f0 methods',
|
667 |
-
choices=['pm', 'rmvpe'],
|
668 |
-
value='pm',
|
669 |
-
interactive=True
|
670 |
-
)
|
671 |
-
|
672 |
-
with gr.Accordion('更多设置', open=False):
|
673 |
-
feat_ratio = gr.Slider(
|
674 |
-
label='Feature ratio',
|
675 |
-
minimum=0,
|
676 |
-
maximum=1,
|
677 |
-
step=0.1,
|
678 |
-
value=0.6,
|
679 |
-
visible=False
|
680 |
-
)
|
681 |
-
filter_radius = gr.Slider(
|
682 |
-
label='Filter radius',
|
683 |
-
minimum=0,
|
684 |
-
maximum=7,
|
685 |
step=1,
|
686 |
-
value=
|
687 |
-
visible=False
|
688 |
)
|
689 |
-
|
690 |
-
label='
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
value=1,
|
695 |
-
visible=False
|
696 |
-
|
697 |
)
|
698 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
699 |
[
|
700 |
-
'
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
],
|
706 |
-
label='
|
707 |
-
|
708 |
)
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
m['metadata'].get('name')
|
717 |
)
|
718 |
-
|
719 |
-
|
720 |
-
label='
|
721 |
-
type='index'
|
722 |
-
)
|
723 |
-
|
724 |
-
# Model info
|
725 |
-
with gr.Box():
|
726 |
-
model_info = gr.Markdown(
|
727 |
-
'### AI歌手信息\n'
|
728 |
-
'Please select a model from dropdown above.',
|
729 |
-
elem_id='model_info'
|
730 |
-
)
|
731 |
|
732 |
-
output_audio = gr.Audio(label='AI歌手(无伴奏)', type="filepath")
|
733 |
-
output_msg = gr.Textbox(label='Output message')
|
734 |
with gr.Tab("📺 - 音乐视频"):
|
735 |
with gr.Row():
|
736 |
with gr.Column():
|
737 |
-
inp1 = gr.Textbox(label="
|
738 |
inp2 = new_song
|
739 |
inp3 = gr.Image(source='upload', type='filepath', label="上传一张背景图片吧")
|
740 |
btn = gr.Button("生成您的专属音乐视频吧", variant="primary")
|
741 |
|
742 |
with gr.Column():
|
743 |
out1 = gr.Video(label='您的专属音乐视频')
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
if (
|
748 |
-
multi_examples and
|
749 |
-
multi_examples.get('vc') and multi_examples.get('tts_vc')
|
750 |
-
):
|
751 |
-
with gr.Accordion('Sweet sweet examples', open=False):
|
752 |
-
with gr.Row():
|
753 |
-
# VC Example
|
754 |
-
if multi_examples.get('vc'):
|
755 |
-
gr.Examples(
|
756 |
-
label='Audio conversion examples',
|
757 |
-
examples=multi_examples.get('vc'),
|
758 |
-
inputs=[
|
759 |
-
input_audio, model_index, pitch_adjust, f0_method,
|
760 |
-
feat_ratio
|
761 |
-
],
|
762 |
-
outputs=[output_audio, output_msg, model_info],
|
763 |
-
fn=_example_vc,
|
764 |
-
cache_examples=args.cache_examples,
|
765 |
-
run_on_click=args.cache_examples
|
766 |
-
)
|
767 |
-
|
768 |
-
# Edge TTS Example
|
769 |
-
if multi_examples.get('tts_vc'):
|
770 |
-
gr.Examples(
|
771 |
-
label='TTS conversion examples',
|
772 |
-
examples=multi_examples.get('tts_vc'),
|
773 |
-
inputs=[
|
774 |
-
tts_input, model_index, tts_speaker, pitch_adjust,
|
775 |
-
f0_method, feat_ratio
|
776 |
-
],
|
777 |
-
outputs=[output_audio, output_msg, model_info],
|
778 |
-
fn=_example_edge_tts,
|
779 |
-
cache_examples=args.cache_examples,
|
780 |
-
run_on_click=args.cache_examples
|
781 |
-
)
|
782 |
-
|
783 |
vc_convert_btn.click(
|
784 |
vc_func,
|
785 |
[
|
|
|
36 |
SynthesizerTrnMs768NSFsid_nono
|
37 |
)
|
38 |
from vc_infer_pipeline import VC
|
39 |
+
|
40 |
+
# SadTalker
|
41 |
+
|
42 |
+
import os, sys
|
43 |
+
from src.gradio_demo import SadTalker
|
44 |
+
|
45 |
+
|
46 |
+
try:
|
47 |
+
import webui # in webui
|
48 |
+
in_webui = True
|
49 |
+
except:
|
50 |
+
in_webui = False
|
51 |
+
|
52 |
+
|
53 |
+
def toggle_audio_file(choice):
|
54 |
+
if choice == False:
|
55 |
+
return gr.update(visible=True), gr.update(visible=False)
|
56 |
+
else:
|
57 |
+
return gr.update(visible=False), gr.update(visible=True)
|
58 |
+
|
59 |
+
def ref_video_fn(path_of_ref_video):
|
60 |
+
if path_of_ref_video is not None:
|
61 |
+
return gr.update(value=True)
|
62 |
+
else:
|
63 |
+
return gr.update(value=False)
|
64 |
+
|
65 |
+
sad_talker = SadTalker("checkpoints", "src/config", lazy_load=True)
|
66 |
|
67 |
# Reference: https://huggingface.co/spaces/zomehwh/rvc-models/blob/main/app.py#L21 # noqa
|
68 |
in_hf_space = getenv('SYSTEM') == 'spaces'
|
|
|
656 |
as_audio_submit.click(fn=audio_separated, inputs=[as_audio_input], outputs=[as_audio_vocals, as_audio_no_vocals, as_audio_message], show_progress=True, queue=True)
|
657 |
|
658 |
with gr.Row():
|
659 |
+
with gr.Tab('🎶 - 歌声转换'):
|
660 |
+
with gr.Column():
|
661 |
input_audio = as_audio_vocals
|
662 |
vc_convert_btn = gr.Button('进行歌声转换吧!', variant='primary')
|
663 |
full_song = gr.Button("加入歌曲伴奏吧!", variant="primary")
|
664 |
new_song = gr.Audio(label="AI歌手+伴奏", type="filepath")
|
665 |
|
666 |
+
pitch_adjust = gr.Slider(
|
667 |
+
label='Pitch',
|
668 |
+
minimum=-24,
|
669 |
+
maximum=24,
|
670 |
+
step=1,
|
671 |
+
value=0
|
672 |
+
)
|
673 |
+
f0_method = gr.Radio(
|
674 |
+
label='f0 methods',
|
675 |
+
choices=['pm', 'rmvpe'],
|
676 |
+
value='pm',
|
677 |
+
interactive=True
|
678 |
+
)
|
679 |
+
|
680 |
+
with gr.Accordion('更多设置', open=False):
|
681 |
+
feat_ratio = gr.Slider(
|
682 |
+
label='Feature ratio',
|
683 |
+
minimum=0,
|
684 |
+
maximum=1,
|
685 |
+
step=0.1,
|
686 |
+
value=0.6,
|
687 |
+
visible=False
|
688 |
+
)
|
689 |
+
filter_radius = gr.Slider(
|
690 |
+
label='Filter radius',
|
691 |
+
minimum=0,
|
692 |
+
maximum=7,
|
693 |
+
step=1,
|
694 |
+
value=3,
|
695 |
+
visible=False
|
696 |
+
)
|
697 |
+
rms_mix_rate = gr.Slider(
|
698 |
+
label='Volume envelope mix rate',
|
699 |
+
minimum=0,
|
700 |
+
maximum=1,
|
701 |
+
step=0.1,
|
702 |
+
value=1,
|
703 |
+
visible=False
|
704 |
+
)
|
705 |
+
resample_rate = gr.Dropdown(
|
706 |
+
[
|
707 |
+
'Disable resampling',
|
708 |
+
'16000',
|
709 |
+
'22050',
|
710 |
+
'44100',
|
711 |
+
'48000'
|
712 |
+
],
|
713 |
+
label='Resample rate',
|
714 |
+
value='Disable resampling'
|
715 |
+
)
|
716 |
+
|
717 |
+
with gr.Column():
|
718 |
+
# Model select
|
719 |
+
model_index = gr.Dropdown(
|
720 |
+
[
|
721 |
+
'%s - %s' % (
|
722 |
+
m['metadata'].get('source', 'Unknown'),
|
723 |
+
m['metadata'].get('name')
|
724 |
+
)
|
725 |
+
for m in loaded_models
|
726 |
+
],
|
727 |
+
label='请选择您的AI歌手(必选)',
|
728 |
+
type='index'
|
729 |
+
)
|
730 |
+
|
731 |
+
# Model info
|
732 |
+
with gr.Box():
|
733 |
+
model_info = gr.Markdown(
|
734 |
+
'### AI歌手信息\n'
|
735 |
+
'Please select a model from dropdown above.',
|
736 |
+
elem_id='model_info'
|
737 |
+
)
|
738 |
+
|
739 |
+
output_audio = gr.Audio(label='AI歌手(无伴奏)', type="filepath")
|
740 |
+
output_msg = gr.Textbox(label='Output message')
|
741 |
+
|
742 |
+
with gr.Tab('🎙️ - 文本转语音'):
|
743 |
+
with gr.Column():
|
744 |
tts_input = gr.Textbox(
|
745 |
label='请填写您想要转换的文本(中英皆可)',
|
746 |
lines=3
|
|
|
758 |
)
|
759 |
|
760 |
tts_convert_btn = gr.Button('进行AI变声吧', variant='primary')
|
761 |
+
pitch_adjust = gr.Slider(
|
762 |
+
label='Pitch',
|
763 |
+
minimum=-24,
|
764 |
+
maximum=24,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
765 |
step=1,
|
766 |
+
value=0
|
|
|
767 |
)
|
768 |
+
f0_method = gr.Radio(
|
769 |
+
label='f0 methods',
|
770 |
+
choices=['pm', 'rmvpe'],
|
771 |
+
value='pm',
|
772 |
+
interactive=True
|
|
|
|
|
|
|
773 |
)
|
774 |
+
|
775 |
+
with gr.Accordion('更多设置', open=False):
|
776 |
+
feat_ratio = gr.Slider(
|
777 |
+
label='Feature ratio',
|
778 |
+
minimum=0,
|
779 |
+
maximum=1,
|
780 |
+
step=0.1,
|
781 |
+
value=0.6,
|
782 |
+
visible=False
|
783 |
+
)
|
784 |
+
filter_radius = gr.Slider(
|
785 |
+
label='Filter radius',
|
786 |
+
minimum=0,
|
787 |
+
maximum=7,
|
788 |
+
step=1,
|
789 |
+
value=3,
|
790 |
+
visible=False
|
791 |
+
)
|
792 |
+
rms_mix_rate = gr.Slider(
|
793 |
+
label='Volume envelope mix rate',
|
794 |
+
minimum=0,
|
795 |
+
maximum=1,
|
796 |
+
step=0.1,
|
797 |
+
value=1,
|
798 |
+
visible=False
|
799 |
+
)
|
800 |
+
resample_rate = gr.Dropdown(
|
801 |
+
[
|
802 |
+
'Disable resampling',
|
803 |
+
'16000',
|
804 |
+
'22050',
|
805 |
+
'44100',
|
806 |
+
'48000'
|
807 |
+
],
|
808 |
+
label='Resample rate',
|
809 |
+
value='Disable resampling'
|
810 |
+
)
|
811 |
+
|
812 |
+
with gr.Column():
|
813 |
+
# Model select
|
814 |
+
model_index = gr.Dropdown(
|
815 |
[
|
816 |
+
'%s - %s' % (
|
817 |
+
m['metadata'].get('source', 'Unknown'),
|
818 |
+
m['metadata'].get('name')
|
819 |
+
)
|
820 |
+
for m in loaded_models
|
821 |
],
|
822 |
+
label='请选择您的AI歌手(必选)',
|
823 |
+
type='index'
|
824 |
)
|
825 |
+
|
826 |
+
# Model info
|
827 |
+
with gr.Box():
|
828 |
+
model_info = gr.Markdown(
|
829 |
+
'### AI歌手信息\n'
|
830 |
+
'Please select a model from dropdown above.',
|
831 |
+
elem_id='model_info'
|
|
|
832 |
)
|
833 |
+
|
834 |
+
output_audio = gr.Audio(label='AI歌手(无伴奏)', type="filepath")
|
835 |
+
output_msg = gr.Textbox(label='Output message')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
|
|
|
|
|
837 |
with gr.Tab("📺 - 音乐视频"):
|
838 |
with gr.Row():
|
839 |
with gr.Column():
|
840 |
+
inp1 = gr.Textbox(label="为视频配上精彩的文案吧(选填;英文)")
|
841 |
inp2 = new_song
|
842 |
inp3 = gr.Image(source='upload', type='filepath', label="上传一张背景图片吧")
|
843 |
btn = gr.Button("生成您的专属音乐视频吧", variant="primary")
|
844 |
|
845 |
with gr.Column():
|
846 |
out1 = gr.Video(label='您的专属音乐视频')
|
847 |
+
|
848 |
+
btn.click(fn=infer, inputs=[inp1, inp2, inp3], outputs=[out1])
|
849 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
850 |
vc_convert_btn.click(
|
851 |
vc_func,
|
852 |
[
|