|
|
|
import torch |
|
from transformers import pipeline, AutoTokenizer, AutoModel |
|
import gradio as gr |
|
|
|
|
|
pipe = pipeline("feature-extraction", model="ArthurZ/jukebox-1b-lyrics", ignore_mismatched_sizes=True) |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained("ArthurZ/jukebox-1b-lyrics", ignore_mismatched_sizes=True) |
|
model = AutoModel.from_pretrained("ArthurZ/jukebox-1b-lyrics", ignore_mismatched_sizes=True) |
|
|
|
|
|
def generate_audio(text): |
|
|
|
inputs = tokenizer(text, return_tensors="pt") |
|
|
|
|
|
with torch.no_grad(): |
|
outputs = model(**inputs) |
|
|
|
|
|
|
|
return outputs.last_hidden_state.mean().numpy() |
|
|
|
|
|
interface = gr.Interface(fn=generate_audio, inputs="text", outputs="text", title="Jukebox Lyrics Model") |
|
|
|
|
|
interface.launch() |
|
|