File size: 2,116 Bytes
12bfd03
 
 
 
 
 
 
8a00872
1786359
12bfd03
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import sys
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')
os.system('cd pretrained_models/speech_kantts_ttsfrd/ && ttsfrd-0.3.9-cp310-cp310-linux_x86_64.whl')
os.system('sed -i s@pydantic.typing@typing_extensions@g /opt/conda/lib/python3.8/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])

demo.queue().launch(server_port=50000)