Spaces:
Running
on
Zero
Running
on
Zero
Merge branch 'main' of https://huggingface.co/spaces/declare-lab/JAM
Browse files- .gitattributes +0 -1
- app.py +3 -53
- requirements.txt +0 -2
.gitattributes
CHANGED
@@ -1 +0,0 @@
|
|
1 |
-
# No LFS configuration - all files stored as regular Git files
|
|
|
|
app.py
CHANGED
@@ -4,14 +4,10 @@ import os
|
|
4 |
import json
|
5 |
import tempfile
|
6 |
from pathlib import Path
|
7 |
-
|
8 |
from model import Jamify
|
9 |
-
<<<<<<< HEAD
|
10 |
-
import json
|
11 |
-
=======
|
12 |
from utils import json_to_text, text_to_json
|
13 |
|
14 |
-
>>>>>>> working
|
15 |
# Initialize the Jamify model once
|
16 |
print("Initializing Jamify model...")
|
17 |
jamify_model = Jamify()
|
@@ -19,51 +15,15 @@ print("Jamify model ready.")
|
|
19 |
|
20 |
|
21 |
|
22 |
-
|
23 |
-
def parse(file):
|
24 |
-
parsed_data = []
|
25 |
-
with open(file, 'r') as f:
|
26 |
-
content = f.read()
|
27 |
-
for line in f:
|
28 |
-
line = line.strip()
|
29 |
-
if not line:
|
30 |
-
continue
|
31 |
-
start,end,word = line.split(' ')
|
32 |
-
data_point = {
|
33 |
-
"word": word,
|
34 |
-
"start": float(start),
|
35 |
-
"end": float(end)
|
36 |
-
}
|
37 |
-
parsed_data.append(data_point)
|
38 |
-
|
39 |
-
with open('temp.json','w') as f:
|
40 |
-
json.dump(parsed_data,f)
|
41 |
-
|
42 |
-
return content
|
43 |
|
44 |
@spaces.GPU(duration=100)
|
45 |
def generate_song(reference_audio, lyrics_text, style_prompt, duration):
|
46 |
# We need to save the uploaded files to temporary paths to pass to the model
|
47 |
reference_audio = reference_audio not in ("", None) and reference_audio or None
|
48 |
|
49 |
-
<<<<<<< HEAD
|
50 |
-
|
51 |
-
# The model expects paths, so we write the prompt to a temp file if needed
|
52 |
-
# (This part of the model could be improved to accept the string directly)
|
53 |
-
#print(type(lyrics_file))
|
54 |
-
#parse(lyrics_file)
|
55 |
-
#parse(lyrics_file)
|
56 |
-
output_path = jamify_model.predict(
|
57 |
-
reference_audio_path=reference_audio,
|
58 |
-
lyrics_json_path='temp.json',
|
59 |
-
style_prompt=style_prompt,
|
60 |
-
duration_sec=duration
|
61 |
-
|
62 |
-
)
|
63 |
-
=======
|
64 |
# Convert text format to JSON and save to temporary file
|
65 |
lyrics_json = text_to_json(lyrics_text)
|
66 |
-
>>>>>>> working
|
67 |
|
68 |
# Create temporary file for lyrics JSON
|
69 |
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
@@ -136,16 +96,6 @@ def load_example(example_idx, examples):
|
|
136 |
examples = load_examples()
|
137 |
|
138 |
# Gradio interface
|
139 |
-
def process_text_file(file_obj):
|
140 |
-
"""
|
141 |
-
Reads the content of an uploaded text file.
|
142 |
-
"""
|
143 |
-
if file_obj is not None:
|
144 |
-
with open(file_obj.name, 'r') as f:
|
145 |
-
content = f.read()
|
146 |
-
return content
|
147 |
-
return "No file uploaded."
|
148 |
-
|
149 |
with gr.Blocks() as demo:
|
150 |
gr.Markdown("# Jamify: Music Generation from Lyrics and Style")
|
151 |
gr.Markdown("Provide your lyrics, a style reference (either an audio file or a text prompt), and a desired duration to generate a song.")
|
@@ -204,4 +154,4 @@ try:
|
|
204 |
except Exception as e:
|
205 |
print(f"Warning: Could not create temporary directories: {e}")
|
206 |
|
207 |
-
demo.queue().launch()
|
|
|
4 |
import json
|
5 |
import tempfile
|
6 |
from pathlib import Path
|
7 |
+
|
8 |
from model import Jamify
|
|
|
|
|
|
|
9 |
from utils import json_to_text, text_to_json
|
10 |
|
|
|
11 |
# Initialize the Jamify model once
|
12 |
print("Initializing Jamify model...")
|
13 |
jamify_model = Jamify()
|
|
|
15 |
|
16 |
|
17 |
|
18 |
+
gr.set_static_paths(paths=[Path.cwd().absolute()])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
@spaces.GPU(duration=100)
|
21 |
def generate_song(reference_audio, lyrics_text, style_prompt, duration):
|
22 |
# We need to save the uploaded files to temporary paths to pass to the model
|
23 |
reference_audio = reference_audio not in ("", None) and reference_audio or None
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
# Convert text format to JSON and save to temporary file
|
26 |
lyrics_json = text_to_json(lyrics_text)
|
|
|
27 |
|
28 |
# Create temporary file for lyrics JSON
|
29 |
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
|
|
96 |
examples = load_examples()
|
97 |
|
98 |
# Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
with gr.Blocks() as demo:
|
100 |
gr.Markdown("# Jamify: Music Generation from Lyrics and Style")
|
101 |
gr.Markdown("Provide your lyrics, a style reference (either an audio file or a text prompt), and a desired duration to generate a song.")
|
|
|
154 |
except Exception as e:
|
155 |
print(f"Warning: Could not create temporary directories: {e}")
|
156 |
|
157 |
+
demo.queue().launch()
|
requirements.txt
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
transformers<=4.49.0
|
2 |
torchaudio
|
3 |
diffusers
|
4 |
accelerate
|
@@ -16,7 +15,6 @@ librosa
|
|
16 |
jiwer
|
17 |
demucs
|
18 |
audiobox-aesthetics
|
19 |
-
transformers==4.53.0
|
20 |
|
21 |
# WebDataset
|
22 |
webdataset
|
|
|
|
|
1 |
torchaudio
|
2 |
diffusers
|
3 |
accelerate
|
|
|
15 |
jiwer
|
16 |
demucs
|
17 |
audiobox-aesthetics
|
|
|
18 |
|
19 |
# WebDataset
|
20 |
webdataset
|