File size: 1,493 Bytes
c6fd5b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pathlib import Path

import gradio as gr

from tts_service.functions import generate_speech_from_text
from tts_service.voices import voice_manager

sample = Path("notebooks/sample.txt").read_text()


# TTS tab
def tts_tab():
    with gr.Column():  # noqa: SIM117
        with gr.Row():
            voice_name = gr.Dropdown(
                label="Voice Model",
                info="Select the voice model.",
                choices=voice_manager.voice_names,
                value=voice_manager.voice_names[0],
            )

            tts_rate = gr.Slider(
                minimum=-100,
                maximum=100,
                step=1,
                label="TTS Speed",
                info="Increase or decrease TTS speed.",
                value=0,
                interactive=True,
            )

    tts_text = gr.Textbox(
        label="Text to Synthesize",
        info="Enter the text to synthesize.",
        placeholder="Enter text to synthesize",
        value=sample,
        lines=3,
    )

    convert_button = gr.Button("Convert")

    with gr.Row():
        vc_output1 = gr.Textbox(
            label="Output Information",
            info="The output information will be displayed here.",
        )
        vc_output2 = gr.Audio(label="Generated Audio")

    convert_button.click(
        fn=generate_speech_from_text,
        inputs=[
            tts_text,
            voice_name,
            tts_rate,
        ],
        outputs=[vc_output1, vc_output2],
    )