Spaces:
Running
on
Zero
Running
on
Zero
Redined Usage
Browse files
app.py
CHANGED
@@ -1,55 +1,30 @@
|
|
1 |
-
# WebUI by mrfakename <X @realmrfakename / HF @mrfakename>
|
2 |
-
# Demo also available on HF Spaces: https://huggingface.co/spaces/mrfakename/MeloTTS
|
3 |
import gradio as gr
|
|
|
4 |
import os, torch, io
|
5 |
os.system('python -m unidic download')
|
6 |
# print("Make sure you've downloaded unidic (python -m unidic download) for this WebUI to work.")
|
7 |
from melo.api import TTS
|
8 |
-
speed = 1.0
|
9 |
import tempfile
|
10 |
-
|
11 |
-
models = {
|
12 |
-
'EN': TTS(language='EN', device=device),
|
13 |
-
'ES': TTS(language='ES', device=device),
|
14 |
-
'FR': TTS(language='FR', device=device),
|
15 |
-
'ZH': TTS(language='ZH', device=device),
|
16 |
-
'JP': TTS(language='JP', device=device),
|
17 |
-
'KR': TTS(language='KR', device=device),
|
18 |
-
}
|
19 |
-
speaker_ids = models['EN'].hps.data.spk2id
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
'
|
25 |
-
'
|
26 |
-
'
|
27 |
-
'KR': '최근 텍스트 음성 변환 분야가 급속도로 발전하고 있습니다.',
|
28 |
-
}
|
29 |
-
|
30 |
-
def synthesize(speaker, text, speed, language, progress=gr.Progress()):
|
31 |
bio = io.BytesIO()
|
32 |
-
models[language].tts_to_file(text,
|
33 |
return bio.getvalue()
|
34 |
-
|
35 |
-
|
36 |
-
newtext = default_text_dict[language]
|
37 |
-
else:
|
38 |
-
newtext = text
|
39 |
-
return gr.update(value=list(models[language].hps.data.spk2id.keys())[0], choices=list(models[language].hps.data.spk2id.keys())), newtext
|
40 |
with gr.Blocks() as demo:
|
41 |
-
gr.Markdown('#
|
42 |
with gr.Group():
|
43 |
-
|
44 |
-
|
45 |
-
speed = gr.Slider(label='Speed', minimum=0.1, maximum=10.0, value=1.0, interactive=True, step=0.1)
|
46 |
-
text = gr.Textbox(label="Text to speak", value=default_text_dict['EN'])
|
47 |
-
language.input(load_speakers, inputs=[language, text], outputs=[speaker, text])
|
48 |
-
btn = gr.Button('Synthesize', variant='primary')
|
49 |
aud = gr.Audio(interactive=False)
|
50 |
-
btn.click(synthesize, inputs=[
|
51 |
-
gr.Markdown('Demo by [mrfakename](https://twitter.com/realmrfakename).')
|
52 |
-
|
53 |
|
54 |
demo.queue(api_open=True, default_concurrency_limit=10).launch(show_api=True)
|
55 |
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import spaces
|
3 |
import os, torch, io
|
4 |
os.system('python -m unidic download')
|
5 |
# print("Make sure you've downloaded unidic (python -m unidic download) for this WebUI to work.")
|
6 |
from melo.api import TTS
|
|
|
7 |
import tempfile
|
8 |
+
speaker_ids = model.hps.data.spk2id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
@spaces.GPU
|
11 |
+
def synthesize(text, speed, progress=gr.Progress()):
|
12 |
+
speed = 1.0
|
13 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
14 |
+
model= TTS(language='EN', device=device),
|
15 |
+
speakers=['EN-US','EN-Default']
|
|
|
|
|
|
|
|
|
16 |
bio = io.BytesIO()
|
17 |
+
models[language].tts_to_file(text, model.hps.data.spk2id[speakers[0]], bio, speed=speed, pbar=progress.tqdm, format='wav')
|
18 |
return bio.getvalue()
|
19 |
+
|
20 |
+
|
|
|
|
|
|
|
|
|
21 |
with gr.Blocks() as demo:
|
22 |
+
gr.Markdown('# Article to Podcast')
|
23 |
with gr.Group():
|
24 |
+
text = gr.Textbox(label="Article Link")
|
25 |
+
btn = gr.Button('Podcasitfy', variant='primary')
|
|
|
|
|
|
|
|
|
26 |
aud = gr.Audio(interactive=False)
|
27 |
+
btn.click(synthesize, inputs=[text], outputs=[aud])
|
|
|
|
|
28 |
|
29 |
demo.queue(api_open=True, default_concurrency_limit=10).launch(show_api=True)
|
30 |
|