import gradio as gr from transformers import pipeline # Initialize the text-to-audio pipeline with the MusicGen small model pipe = pipeline("text-to-audio", model="facebook/musicgen-small") # Define the function to generate audio from text def generate_audio(text): audio_output = pipe(text) return audio_output["audio"] # Set up the Gradio interface using updated components app = gr.Interface( fn=generate_audio, # Function to call for text-to-audio generation inputs=gr.Textbox(lines=2, placeholder="Enter text to generate audio"), # Updated input field for text outputs=gr.Audio(type="numpy"), # Updated output for audio title="Text to Audio Generator", # Title of the app description="Generate music or audio from text using Facebook's MusicGen small model." ) # Launch the app if __name__ == "__main__": app.launch()