Spaces:
Sleeping
Sleeping
Create pack_builder/zip_builder.py
Browse files- pack_builder/zip_builder.py +41 -0
pack_builder/zip_builder.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import zipfile
|
| 2 |
+
import uuid
|
| 3 |
+
import os
|
| 4 |
+
from beat_generator.riffusion_cpu import generate_audio_loop
|
| 5 |
+
from content_generator.hooks import generate_hooks
|
| 6 |
+
from content_generator.captions import generate_captions
|
| 7 |
+
from content_generator.ideas import generate_content_ideas
|
| 8 |
+
from content_generator.scripts import generate_short_scripts
|
| 9 |
+
|
| 10 |
+
def build_creator_pack(niche, style, bpm, tone, goal):
|
| 11 |
+
folder = f"assets/temp/{uuid.uuid4().hex}"
|
| 12 |
+
os.makedirs(folder, exist_ok=True)
|
| 13 |
+
|
| 14 |
+
# Beats
|
| 15 |
+
for i in range(3):
|
| 16 |
+
beat_path = generate_audio_loop(style, bpm)
|
| 17 |
+
os.system(f"cp {beat_path} {folder}/beat_{i+1}.wav")
|
| 18 |
+
|
| 19 |
+
# Text Packs
|
| 20 |
+
with open(f"{folder}/hooks.txt", "w") as f:
|
| 21 |
+
f.write("\n".join(generate_hooks(niche, tone)))
|
| 22 |
+
|
| 23 |
+
with open(f"{folder}/captions.txt", "w") as f:
|
| 24 |
+
f.write("\n".join(generate_captions(niche, tone)))
|
| 25 |
+
|
| 26 |
+
with open(f"{folder}/ideas.txt", "w") as f:
|
| 27 |
+
f.write("\n".join(generate_content_ideas(niche, goal)))
|
| 28 |
+
|
| 29 |
+
with open(f"{folder}/scripts.txt", "w") as f:
|
| 30 |
+
f.write("\n".join(generate_short_scripts(niche, tone)))
|
| 31 |
+
|
| 32 |
+
# ZIP
|
| 33 |
+
zip_path = f"{folder}.zip"
|
| 34 |
+
with zipfile.ZipFile(zip_path, "w") as zipf:
|
| 35 |
+
for root, _, files in os.walk(folder):
|
| 36 |
+
for file in files:
|
| 37 |
+
p = os.path.join(root, file)
|
| 38 |
+
arc = os.path.relpath(p, folder)
|
| 39 |
+
zipf.write(p, arc)
|
| 40 |
+
|
| 41 |
+
return zip_path
|