File size: 1,422 Bytes
bcfd9f0
 
 
 
 
 
 
 
 
 
 
 
 
 
e7ddf04
bcfd9f0
bda1f55
bcfd9f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367c379
bcfd9f0
 
 
 
 
 
 
 
 
 
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
import tempfile
import gradio as gr
from synthesize import synthesize, load_model
from synthesis.vocoders import Hifigan

model = load_model("checkpoints/checkpoint_9000.zip")
vocoder = Hifigan("weights/custom_pctest/model.pt", "weights/custom_pctest/config.json")

title = "Text-to-Speech (TTS) model for Priyanka Chopra's voice"
description = "Generate english speech from text using a Tacotron2 model" \
              
article = """<p style='text-align: center'>
                <a href='https://rushichaudhari.github.io/posts/2022-01-12-lets-clone-the-voice-of-priyanka-chopra-jonas/' 
                target='blank' 
                class='footer'>Blog</a></p>"""
examples = ["Generate english speech from text using a Tacotron2 model.", 
            "Two roads diverged in a wood, I took the one less traveled by, And that has made all the difference."]

def inference(text: str):
    synthesize(
        model=model,
        text=text,
        graph_path="graph.png",
        audio_path="audio.wav",
        vocoder=vocoder,
    )
    return "audio.wav"

gr.Interface(
    fn=inference,
    inputs=[
        gr.inputs.Textbox(
            label="Input",
            default=examples[0],
        ),
    ],
    outputs=gr.outputs.Audio(label="Output"),
    title=title,
    description=description,
    article=article,
    examples=examples,
    enable_queue=True,
    allow_flagging=False,
    ).launch(debug=False)