Spaces:
Running
Running
File size: 1,016 Bytes
66c557e f4a57a2 66c557e f4a57a2 66c557e f4a57a2 b04d3bf d4c4038 b04d3bf f4a57a2 9a394c4 f4a57a2 |
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 |
import gradio as gr
import torch
import random
import string
language = 'cyrillic'
model_id = 'v4_cyrillic'
sample_rate = 48000
speaker = 'b_krc'
device = torch.device('cpu')
model, example_text = torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_tts',
language=language,
speaker=model_id)
model.to(device) # gpu or cpu
def tts(text):
random_string = ''.join(random.choices(string.ascii_letters, k=8))
model.save_wav(
audio_path=f'{random_string}.wav',
text=text,
speaker=speaker,
sample_rate=sample_rate
)
return f'{random_string}.wav'
iface = gr.Interface(
fn=tts,
inputs=gr.Textbox(
label="Text",
value="Кюн ахшы болсун",
),
outputs=gr.Audio(label="Output", type='filepath'),
title="Karachay-Malkar TTS",
live=False
)
iface.launch(share=False) |