Spaces:
Runtime error
Runtime error
Robert Jones
commited on
Commit
Β·
2f3ec08
0
Parent(s):
Clean SongBloom Space setup
Browse files- README.md +13 -0
- app.py +73 -0
- requirements.txt +4 -0
README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: SongBloom AI Music Generator
|
| 3 |
+
emoji: π΅
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: gradio
|
| 7 |
+
app_file: app.py
|
| 8 |
+
hardware: t4-small
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# SongBloom AI Music Generator
|
| 12 |
+
|
| 13 |
+
AI music generation from lyrics and audio prompts.
|
app.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
import tempfile
|
| 5 |
+
import shutil
|
| 6 |
+
import subprocess
|
| 7 |
+
|
| 8 |
+
def generate_song(lyrics, audio_file):
|
| 9 |
+
if not lyrics.strip():
|
| 10 |
+
return None, "β Please enter some lyrics!"
|
| 11 |
+
|
| 12 |
+
if audio_file is None:
|
| 13 |
+
return None, "β Please upload an audio prompt file!"
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
# Create input files
|
| 17 |
+
audio_filename = "prompt.wav"
|
| 18 |
+
shutil.copy(audio_file, audio_filename)
|
| 19 |
+
|
| 20 |
+
# Create JSONL input
|
| 21 |
+
jsonl_filename = "input.jsonl"
|
| 22 |
+
input_data = {
|
| 23 |
+
"idx": "1",
|
| 24 |
+
"lyrics": lyrics.strip(),
|
| 25 |
+
"prompt_wav": audio_filename
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
with open(jsonl_filename, 'w') as f:
|
| 29 |
+
json.dump(input_data, f)
|
| 30 |
+
|
| 31 |
+
return None, "π΅ SongBloom setup complete! (Model files will be downloaded automatically on first run)"
|
| 32 |
+
|
| 33 |
+
except Exception as e:
|
| 34 |
+
return None, f"β Error: {str(e)}"
|
| 35 |
+
|
| 36 |
+
# Create interface
|
| 37 |
+
with gr.Blocks(title="SongBloom AI Music Generator") as demo:
|
| 38 |
+
gr.Markdown("# π΅ SongBloom AI Music Generator")
|
| 39 |
+
|
| 40 |
+
with gr.Row():
|
| 41 |
+
with gr.Column():
|
| 42 |
+
lyrics_input = gr.Textbox(
|
| 43 |
+
label="Song Lyrics",
|
| 44 |
+
placeholder="Enter your song lyrics...",
|
| 45 |
+
lines=6,
|
| 46 |
+
value="Here comes the sun, and I say it's all right"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
audio_input = gr.File(
|
| 50 |
+
label="Audio Style Prompt (WAV/MP3)",
|
| 51 |
+
file_types=[".wav", ".mp3"],
|
| 52 |
+
type="filepath"
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
generate_btn = gr.Button("π΅ Generate Song", variant="primary")
|
| 56 |
+
|
| 57 |
+
with gr.Column():
|
| 58 |
+
status_output = gr.Textbox(
|
| 59 |
+
label="Status",
|
| 60 |
+
lines=6,
|
| 61 |
+
interactive=False
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
audio_output = gr.Audio(label="Generated Song")
|
| 65 |
+
|
| 66 |
+
generate_btn.click(
|
| 67 |
+
fn=generate_song,
|
| 68 |
+
inputs=[lyrics_input, audio_input],
|
| 69 |
+
outputs=[audio_output, status_output]
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
if __name__ == "__main__":
|
| 73 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
torch
|
| 3 |
+
torchaudio
|
| 4 |
+
huggingface_hub
|