File size: 4,038 Bytes
f7defef
 
 
ab62ea1
12bfd03
 
fa47fc6
 
12bfd03
 
 
 
 
8a00872
49278e3
 
9c61515
3a987ad
12bfd03
 
 
 
 
 
a2ad7fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12bfd03
 
4039743
12bfd03
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a2ad7fa
12bfd03
 
 
 
 
 
 
 
 
 
 
 
 
 
f7defef
9d1ad25
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
98
99
100
101
102
103
104
105
106
import logging
logging.basicConfig(level=logging.INFO)

import spaces
import os
import sys
os.symlink("/usr/lib/x86_64-linux-gnu/libsox.so.3", "/usr/lib/x86_64-linux-gnu/libsox.so")

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append('{}/third_party/AcademiCodec'.format(ROOT_DIR))
sys.path.append('{}/third_party/Matcha-TTS'.format(ROOT_DIR))

from modelscope import snapshot_download
snapshot_download('speech_tts/speech_kantts_ttsfrd',revision="master", allow_file_pattern='ttsfrd-0.3.9-cp310-cp310-linux_x86_64.whl', local_dir='pretrained_models/speech_kantts_ttsfrd')
snapshot_download('speech_tts/speech_kantts_ttsfrd',revision="master", allow_file_pattern='ttsfrd_dependency-0.1-py3-none-any.whl', local_dir='pretrained_models/speech_kantts_ttsfrd')
os.system('cd pretrained_models/speech_kantts_ttsfrd/ && pip install ttsfrd_dependency-0.1-py3-none-any.whl')
os.system('cd pretrained_models/speech_kantts_ttsfrd/ && pip install ttsfrd-0.3.9-cp310-cp310-linux_x86_64.whl')
os.system('sed -i [email protected]@typing_extensions@g /usr/local/lib/python3.10/site-packages/inflect/__init__.py')

import gradio as gr
from css.advanced import advanced
from css.custom import custom
from css.preset import preset

# audio_mode_choices = [('预置语音生成', 'preset'), ('定制语音生成(复刻录制声音)', 'custom'),
#                       ('高级语音生成(自然语言控制)', 'advanced')]



# def on_audio_mode_change(_audio_mode_radio):
#     yield {
#         preset_layout: gr.update(visible=_audio_mode_radio == 'preset'),
#         custom_layout: gr.update(visible=_audio_mode_radio == 'custom'),
#         advanced_layout: gr.update(visible=_audio_mode_radio == 'advanced')
#     }


# custom_css = """
# .full-height {
#     height: 100%;
# }
# """

# default_layout = 'preset'

# with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
#     audio_mode_radio = gr.Radio(choices=audio_mode_choices,
#                                 value=default_layout,
#                                 label="选择语音生成模式")
#     with gr.Row():
#         with gr.Column(visible=default_layout == 'preset') as preset_layout:
#             preset()
#         with gr.Column(visible=default_layout == 'custom') as custom_layout:
#             custom()
#         with gr.Column(
#                 visible=default_layout == 'advanced') as advanced_layout:
#             advanced()

#     audio_mode_radio.change(
#         fn=on_audio_mode_change,
#         inputs=[audio_mode_radio],
#         outputs=[preset_layout, custom_layout, advanced_layout])


audio_mode_choices = [('Preset voice generation', 'preset'), ('Custom voice generation (replicate recorded voice)', 'custom'),
                      ('Advanced voice generation (natural language control)', 'advanced')]



def on_audio_mode_change(_audio_mode_radio):
    yield {
        preset_layout: gr.update(visible=_audio_mode_radio == 'preset'),
        custom_layout: gr.update(visible=_audio_mode_radio == 'custom'),
        advanced_layout: gr.update(visible=_audio_mode_radio == 'advanced')
    }


custom_css = """
.full-height {
    height: 100%;
}
"""

default_layout = 'preset'

with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
    audio_mode_radio = gr.Radio(choices=audio_mode_choices,
                                value=default_layout,
                                label="Select voice generation mode")
    with gr.Row():
        with gr.Column(visible=default_layout == 'preset') as preset_layout:
            preset()
        with gr.Column(visible=default_layout == 'custom') as custom_layout:
            custom()
        with gr.Column(
                visible=default_layout == 'advanced') as advanced_layout:
            advanced()

    audio_mode_radio.change(
        fn=on_audio_mode_change,
        inputs=[audio_mode_radio],
        outputs=[preset_layout, custom_layout, advanced_layout])

#demo.queue().launch(server_port=7860, share=True)
demo.queue().launch(server_port=7860)