File size: 1,570 Bytes
6b28a91 c1af806 6b28a91 a9c020a 6b28a91 a9c020a 6b28a91 97a0727 6b28a91 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import gradio as gr
import os
import shutil
import spaces
import sys
# we will clone the repo and install the dependencies
# NOTE: Still fixing bugs, not release, do not try :) !
os.system('pip install -r qa_mdt/requirements.txt')
os.system('pip install xformers==0.0.26.post1')
os.system('pip install torchlibrosa==0.0.9 librosa==0.9.2')
os.system('pip install -q pytorch_lightning==2.1.3 torchlibrosa==0.0.9 librosa==0.9.2 ftfy==6.1.1 braceexpand')
os.system('pip install torch==2.3.0+cu121 torchvision==0.18.0+cu121 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu121')
os.system('pip install numpy==1.23.5')
# only then import the necessary modules from qa_mdt
from qa_mdt.pipeline import MOSDiffusionPipeline
pipe = MOSDiffusionPipeline()
# this runs the pipeline with user input and saves the output as 'awesome.wav'
@spaces.GPU()
def generate_waveform(description):
pipe(description)
generated_file_path = "./awesome.wav"
if os.path.exists(generated_file_path):
return generated_file_path
else:
return "Error: Failed to generate the waveform."
# gradio interface
iface = gr.Interface(
fn=generate_waveform,
inputs=gr.Textbox(lines=2, placeholder="Enter a music description here..."),
outputs=gr.Audio(label="Download the Music 🎼"),
title="Flux Music Diffusion Pipeline",
description="Enter a music description, and the model will generate a corresponding audio waveform. Download the output as 'awesome.wav'."
)
# Launch the Gradio app
if __name__ == "__main__":
iface.launch()
|