fffiloni's picture
Update app.py
84f3437
raw
history blame
710 Bytes
import gradio as gr
import torch
from transformers import BarkModel
from optimum.bettertransformer import BetterTransformer
bark_model = BarkModel.from_pretrained("suno/bark", torch_dtype=torch.float16)
from TTS.tts.configs.bark_config import BarkConfig
from TTS.tts.models.bark import Bark
config = BarkConfig()
model = Bark.init_from_config(config)
model.load_checkpoint(config, checkpoint_dir=bark_model, eval=True)
def infer(prompt):
text = "Hello, my name is Manmay , how are you?"
# with random speaker
output_dict = model.synthesize(text, config, speaker_id="random", voice_dirs=None)
return "done"
gr.Interface(fn=infer, inputs=[gr.Textbox()], outputs=[gr.Textbox()]).launch()