File size: 984 Bytes
7c206f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import tempfile

import gradio as gr

from neon_tts_plugin_coqui import CoquiTTS


LANGUAGES = [
    "en",
    "pl",
    "uk",
]

coquiTTS = CoquiTTS()


def tts(text: str, language: str):
    print(text, language)
    # return output
    with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
        coquiTTS.get_tts(text, fp, speaker = {"language" : language})
        return fp.name



iface = gr.Interface(
    fn=tts,
    inputs=[
        gr.inputs.Textbox(
            label="Input",
            default="Hello, how are you?",
        ),
        gr.inputs.Radio(
            label="Pick a Language",
            choices=LANGUAGES,
        ),
    ],
    outputs=gr.outputs.Audio(label="Output"),
    title="🐸💬 - NeonAI Coqui AI TTS Plugin",
    theme="huggingface",
    description="🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production",
    article="more info at https://github.com/coqui-ai/TTS",
)
iface.launch()