Alif737 commited on
Commit
91f0321
·
verified ·
1 Parent(s): 3d3bdca
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3
+ import torch
4
+
5
+ # Load pre-trained model and tokenizer
6
+ model_name = "gpt2"
7
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
8
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
9
+
10
+ # Function to generate remix
11
+ def generate_remix(input_text):
12
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids
13
+ output = model.generate(input_ids)
14
+ output_text = tokenizer.decode(output[0], skip_special_tokens=True)
15
+ return output_text
16
+
17
+ # Create Gradio interface
18
+ inputs = gr.inputs.Textbox(lines=5, label="Input Song Lyrics")
19
+ outputs = gr.outputs.Textbox(label="Remixed Song Lyrics")
20
+ title = "Song Remixing Tool"
21
+ description = "Enter the lyrics of a song and get a remix!"
22
+ examples = [["I'm feeling good", "Feeling happy tonight"]]
23
+
24
+ gr.Interface(generate_remix, inputs, outputs, title=title, description=description, examples=examples).launch()