Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,37 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
+
import random
|
4 |
+
import string
|
5 |
|
6 |
+
language = 'cyrillic'
|
7 |
+
model_id = 'v4_cyrillic'
|
8 |
+
sample_rate = 48000
|
9 |
+
speaker = 'b_krc'
|
10 |
+
device = torch.device('cpu')
|
11 |
|
12 |
+
model, example_text = torch.hub.load(repo_or_dir='snakers4/silero-models',
|
13 |
+
model='silero_tts',
|
14 |
+
language=language,
|
15 |
+
speaker=model_id)
|
16 |
+
model.to(device) # gpu or cpu
|
17 |
+
|
18 |
+
def tts(text):
|
19 |
+
random_string = ''.join(random.choices(string.ascii_letters, k=8))
|
20 |
+
model.save_wav(
|
21 |
+
audio_path=f'{random_string}.wav',
|
22 |
+
text=text,
|
23 |
+
speaker=speaker,
|
24 |
+
sample_rate=sample_rate
|
25 |
+
)
|
26 |
+
|
27 |
+
return f'{random_string}.wav'
|
28 |
+
|
29 |
+
iface = gr.Interface(
|
30 |
+
fn=tts,
|
31 |
+
inputs="text",
|
32 |
+
outputs=gr.Audio(label="Output", type='filepath'),
|
33 |
+
title="Karachay-Malkar TTS",
|
34 |
+
live=False
|
35 |
+
)
|
36 |
+
|
37 |
+
iface.launch(share=False)
|