Spaces:
Running
Running
File size: 1,350 Bytes
cfe968b |
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 41 42 43 44 45 46 47 48 49 50 |
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_EXAMPLES, 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() |