File size: 1,036 Bytes
4300fed
610f79e
4300fed
7ffbb2d
 
4300fed
 
610f79e
532dc11
610f79e
 
 
 
 
 
406e977
610f79e
406e977
610f79e
 
4300fed
610f79e
4300fed
610f79e
 
4300fed
610f79e
70cbf96
881961f
532dc11
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
import gradio as gr
import spaces
import os, torch, io
os.system('python -m unidic download')
# print("Make sure you've downloaded unidic (python -m unidic download) for this WebUI to work.")
from melo.api import TTS
import tempfile
speaker_ids = model.hps.data.spk2id

@spaces.GPU
def synthesize(text, speed, progress=gr.Progress()):
    speed = 1.0
    device = 'cuda' if torch.cuda.is_available() else 'cpu'
    model=  TTS(language='EN', device=device),
    speakers=['EN-US','EN-Default']
    bio = io.BytesIO()
    models[language].tts_to_file(text, model.hps.data.spk2id[speakers[0]], bio, speed=speed, pbar=progress.tqdm, format='wav')
    return bio.getvalue()

  
with gr.Blocks() as demo:
    gr.Markdown('# Article to Podcast')
    with gr.Group():
        text = gr.Textbox(label="Article Link")
    btn = gr.Button('Podcasitfy', variant='primary')
    aud = gr.Audio(interactive=False)
    btn.click(synthesize, inputs=[text], outputs=[aud])

demo.queue(api_open=True, default_concurrency_limit=10).launch(show_api=True)