import os from transformers import BarkModel from transformers import AutoProcessor ###### BARK model_bark = BarkModel.from_pretrained("suno/bark") processor_bark = AutoProcessor.from_pretrained("suno/bark") ###### FACEBOOK #from mms import generate_audio_mms from tts import synthesize, TTS_LANGUAGES import torch device = "cuda:0" if torch.cuda.is_available() else "cpu" model_bark = model_bark.to(device) def generate_audio_bark(input): voice_preset = "v2/es_speaker_1" inputs = processor_bark(input, voice_preset=voice_preset) # generate speech sampling_rate = model_bark.generation_config.sample_rate speech_output = model_bark.generate(**inputs.to(device)) return sampling_rate,speech_output[0].cpu().numpy() import gradio as gr with gr.Blocks() as demo: with gr.Tab("MMS"): with gr.Row(): with gr.Column(): textbox = gr.Textbox(label="Ingrese texto") button = gr.Button("Hablar") with gr.Column(): audio_output = gr.Audio() with gr.Tab("Bark"): with gr.Row(): with gr.Column(): textbox2= gr.Textbox(label="Ingrese text") button2 = gr.Button("Hablar") with gr.Column(): audio_output2 = gr.Audio() button.click(synthesize,textbox,audio_output) button2.click(generate_audio_bark,textbox2,audio_output2) demo.launch()