Spaces:
Running
Running
import gradio as gr | |
''' | |
from TTS.api import TTS | |
from bark import SAMPLE_RATE, generate_audio, preload_models | |
from scipy.io.wavfile import write as write_wav | |
#from IPython.display import Audio | |
# download and load all models | |
#preload_models() | |
def bark_try(): | |
# generate audio from text | |
text_prompt = """ | |
Hello, my name is Suno. And, uh — and I like pizza. [laughs] | |
But I also have other interests such as playing tic tac toe. | |
""" | |
audio_array = generate_audio(text_prompt) | |
# save audio to disk | |
write_wav("bark_generation.wav", SAMPLE_RATE, audio_array) | |
# play text in notebook | |
#Audio(audio_array, rate=SAMPLE_RATE) | |
return ("bark_generation.wav") | |
def try1(): | |
#model_name1 = TTS.list_models() | |
#print (f"model1 Name: {model_name1}") | |
#model_name = model_name1[0] | |
#print (f"model2 Name: {model_name}") | |
# Init TTS | |
tts = TTS("tts_models/multilingual/multi-dataset/bark", gpu=False) | |
# Run TTS | |
# Since this model is multi-speaker and multi-lingual, we must set the target speaker and the language | |
# Text to speech with a numpy output | |
#wav = tts.tts("This is a test! This is also a test!!", speaker=tts.speakers[0], language=tts.languages[0]) | |
# Text to speech to a file | |
tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="output.wav") | |
out = "output.wav" | |
return out | |
#def try2(): | |
#tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False) | |
#tts.tts_to_file("This is voice cloning.", speaker_wav="my/cloning/audio.wav", language="en", file_path="output.wav") | |
#tts.tts_to_file("C'est le clonage de la voix.", speaker_wav="my/cloning/audio.wav", language="fr", file_path="output.wav") | |
#tts.tts_to_file("Isso é clonagem de voz.", speaker_wav="my/cloning/audio.wav", language="pt", file_path="output.wav") | |
#out = "output.wav" | |
#return out | |
''' | |
model = gr.Interface.load("models/suno/bark") | |
def bark_try_2(): | |
out = model("this is some text") | |
return out | |
with gr.Blocks() as app: | |
out1 = gr.Audio() | |
btn1 = gr.Button() | |
btn2 = gr.Button() | |
btn1.click(bark_try_2,None,out1) | |
#btn2.click(try1,None,out1) | |
app.launch() |