import gradio as gr from transformers import AutoModelForSeq2SeqLM, AutoTokenizer import torch # Load pre-trained model and tokenizer model_name = "gpt2" model = AutoModelForSeq2SeqLM.from_pretrained(model_name) tokenizer = AutoTokenizer.from_pretrained(model_name) # Function to generate remix def generate_remix(input_text): input_ids = tokenizer(input_text, return_tensors="pt").input_ids output = model.generate(input_ids) output_text = tokenizer.decode(output[0], skip_special_tokens=True) return output_text # Create Gradio interface inputs = gr.inputs.Textbox(lines=5, label="Input Song Lyrics") outputs = gr.outputs.Textbox(label="Remixed Song Lyrics") title = "Song Remixing Tool" description = "Enter the lyrics of a song and get a remix!" examples = [["I'm feeling good", "Feeling happy tonight"]] gr.Interface(generate_remix, inputs, outputs, title=title, description=description, examples=examples).launch()