Spaces:
Runtime error
Runtime error
File size: 888 Bytes
1845fa8 78f9221 1845fa8 78f9221 1845fa8 4151c7e 78f9221 1845fa8 4151c7e 1845fa8 78f9221 |
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 |
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load the model and tokenizer
model_name = "suno/bark-small"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Define the Gradio interface
def text_to_speech(text):
# Tokenize the input text
inputs = tokenizer.encode(text, return_tensors="pt")
# Generate speech from the input text using the loaded model
outputs = model.generate(inputs)
# Convert the generated speech tensor to audio format
speech = gradio.inputs.Audio(outputs)
return speech
# Create the Gradio interface
iface = gr.Interface(fn=text_to_speech, inputs="text", outputs="audio",
title="Text-to-Speech App",
description="Enter text to hear the speech")
# Launch the Gradio interface
iface.launch()
|