from transformers import VitsModel, AutoTokenizer import soundfile as sf import tempfile import gradio as gr tts_model = VitsModel.from_pretrained("facebook/mms-tts-pol") tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-pol") title = "Polish Text-To-Speech model based on facebook/mms-tts-pol" def tts(text: str, language: str): inputs = tokenizer(text, return_tensors="pt") with torch.no_grad(): output = tts_model(**inputs).waveform.squeeze().numpy() sf.write('temp_file.wav', output, tts_model.config.sampling_rate) return 'temp_file.wav' with gr.Blocks() as blocks: gr.Markdown("