Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from beat_generator.riffusion_cpu import generate_audio_loop
|
| 3 |
+
from beat_generator.midi_tools import generate_midi_pattern
|
| 4 |
+
from content_generator.hooks import generate_hooks
|
| 5 |
+
from content_generator.captions import generate_captions
|
| 6 |
+
from content_generator.ideas import generate_content_ideas
|
| 7 |
+
from content_generator.scripts import generate_short_scripts
|
| 8 |
+
from pack_builder.zip_builder import build_creator_pack
|
| 9 |
+
|
| 10 |
+
def ui_generate_beats(style, bpm, loops):
|
| 11 |
+
outputs = []
|
| 12 |
+
for _ in range(loops):
|
| 13 |
+
audio = generate_audio_loop(style, bpm)
|
| 14 |
+
outputs.append(audio)
|
| 15 |
+
return outputs
|
| 16 |
+
|
| 17 |
+
def ui_generate_midi(bpm, pattern_type):
|
| 18 |
+
return generate_midi_pattern(bpm, pattern_type)
|
| 19 |
+
|
| 20 |
+
def ui_generate_content(niche, tone, goal):
|
| 21 |
+
hooks = generate_hooks(niche, tone)
|
| 22 |
+
captions = generate_captions(niche, tone)
|
| 23 |
+
ideas = generate_content_ideas(niche, goal)
|
| 24 |
+
scripts = generate_short_scripts(niche, tone)
|
| 25 |
+
|
| 26 |
+
return (
|
| 27 |
+
"\n".join(hooks),
|
| 28 |
+
"\n".join(captions),
|
| 29 |
+
"\n".join(ideas),
|
| 30 |
+
"\n".join(scripts)
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
def ui_build_pack(niche, style, bpm, tone, goal):
|
| 34 |
+
zip_path = build_creator_pack(niche, style, bpm, tone, goal)
|
| 35 |
+
return zip_path
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
with gr.Blocks(title="AI Content + Beat Generator (Free Tier)") as demo:
|
| 39 |
+
|
| 40 |
+
gr.Markdown("## 🔥 AI Content + Beat Generator (Free Tier Edition)")
|
| 41 |
+
|
| 42 |
+
with gr.Tab("🎵 Beat Generator"):
|
| 43 |
+
style = gr.Dropdown(["Country Rap", "Trap", "Dark Outlaw", "Drill", "BoomBap"], label="Beat Style")
|
| 44 |
+
bpm = gr.Slider(60, 180, value=120, label="BPM")
|
| 45 |
+
loops = gr.Slider(1, 5, value=1, label="Number of Loops")
|
| 46 |
+
generate_btn = gr.Button("Generate Beats")
|
| 47 |
+
audio_out = gr.Audio(label="Generated Beat(s)", type="filepath", interactive=False, visible=True, elem_id="audio_output", streaming=True, multiselect=True)
|
| 48 |
+
generate_btn.click(ui_generate_beats, inputs=[style, bpm, loops], outputs=audio_out)
|
| 49 |
+
|
| 50 |
+
with gr.Tab("🧠 Content Generator"):
|
| 51 |
+
niche = gr.Textbox(label="Niche (Example: Fitness, Real Estate, Barbers, Musicians)")
|
| 52 |
+
tone = gr.Textbox(label="Tone (Example: Motivational, Funny, Serious, Viral)")
|
| 53 |
+
goal = gr.Textbox(label="Goal (Example: Sales, Growth, Engagement, Viral)")
|
| 54 |
+
gen_content_btn = gr.Button("Generate Content")
|
| 55 |
+
hooks_out = gr.Textbox(label="Hooks")
|
| 56 |
+
captions_out = gr.Textbox(label="Captions")
|
| 57 |
+
ideas_out = gr.Textbox(label="Content Ideas")
|
| 58 |
+
scripts_out = gr.Textbox(label="Short Scripts")
|
| 59 |
+
gen_content_btn.click(ui_generate_content, inputs=[niche, tone, goal], outputs=[hooks_out, captions_out, ideas_out, scripts_out])
|
| 60 |
+
|
| 61 |
+
with gr.Tab("📦 Creator Pack Builder (ZIP)"):
|
| 62 |
+
niche2 = gr.Textbox(label="Niche")
|
| 63 |
+
style2 = gr.Dropdown(["Country Rap", "Trap", "Dark Outlaw", "Drill", "BoomBap"], label="Beat Style")
|
| 64 |
+
bpm2 = gr.Slider(60, 180, value=120, label="BPM")
|
| 65 |
+
tone2 = gr.Textbox(label="Tone")
|
| 66 |
+
goal2 = gr.Textbox(label="Goal")
|
| 67 |
+
build_btn = gr.Button("Build Creator Pack")
|
| 68 |
+
zip_out = gr.File(label="Download ZIP")
|
| 69 |
+
build_btn.click(ui_build_pack, inputs=[niche2, style2, bpm2, tone2, goal2], outputs=zip_out)
|
| 70 |
+
|
| 71 |
+
demo.launch()
|