Spaces:
Running
on
Zero
Running
on
Zero
jadechoghari
commited on
Commit
•
6b28a91
1
Parent(s):
4d6c2b2
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
import shutil
|
4 |
+
import spaces
|
5 |
+
|
6 |
+
# we will clone the repo and install the dependencies
|
7 |
+
os.system('git lfs install')
|
8 |
+
os.system('git clone https://huggingface.co/jadechoghari/qa-mdt')
|
9 |
+
os.system('pip install -r qa_mdt/requirements.txt')
|
10 |
+
os.system('pip install xformers==0.0.26.post1')
|
11 |
+
os.system('pip install torchlibrosa==0.0.9 librosa==0.9.2')
|
12 |
+
os.system('pip install -q pytorch_lightning==2.1.3 torchlibrosa==0.0.9 librosa==0.9.2 ftfy==6.1.1 braceexpand')
|
13 |
+
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')
|
14 |
+
|
15 |
+
# only then import the necessary modules from qa_mdt
|
16 |
+
from qa_mdt.pipeline import MOSDiffusionPipeline
|
17 |
+
|
18 |
+
|
19 |
+
pipe = MOSDiffusionPipeline()
|
20 |
+
|
21 |
+
# this runs the pipeline with user input and saves the output as 'awesome.wav'
|
22 |
+
@spaces.GPU()
|
23 |
+
def generate_waveform(description):
|
24 |
+
pipe(description)
|
25 |
+
|
26 |
+
generated_file_path = "./awesome.wav"
|
27 |
+
|
28 |
+
if os.path.exists(generated_file_path):
|
29 |
+
return generated_file_path
|
30 |
+
else:
|
31 |
+
return "Error: Failed to generate the waveform."
|
32 |
+
|
33 |
+
# gradio interface
|
34 |
+
iface = gr.Interface(
|
35 |
+
fn=generate_waveform,
|
36 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter a music description here..."), # Text input for description
|
37 |
+
outputs=gr.outputs.File(label="Download Generated WAV file"), # File output for download
|
38 |
+
title="Flux Music Diffusion Pipeline",
|
39 |
+
description="Enter a music description, and the model will generate a corresponding audio waveform. Download the output as 'awesome.wav'."
|
40 |
+
)
|
41 |
+
|
42 |
+
# Launch the Gradio app
|
43 |
+
if __name__ == "__main__":
|
44 |
+
iface.launch()
|