Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -151,10 +151,10 @@ def generate_sfx(video_path):
|
|
| 151 |
|
| 152 |
# Clean Llama responses (your logic, made more robust)
|
| 153 |
prompts = response_text.splitlines()
|
| 154 |
-
fixed_prompts = [p for p in prompts if p and "
|
| 155 |
-
|
| 156 |
if not fixed_prompts:
|
| 157 |
-
return transcript, prompts,
|
| 158 |
|
| 159 |
# --- Step 3: ElevenLabs Audio Generation ---
|
| 160 |
output_audio_files = []
|
|
@@ -162,12 +162,12 @@ def generate_sfx(video_path):
|
|
| 162 |
|
| 163 |
for i, line in enumerate(fixed_prompts):
|
| 164 |
try:
|
| 165 |
-
parts = line.split("
|
| 166 |
if len(parts) < 2:
|
| 167 |
continue # Skip malformed lines
|
| 168 |
|
| 169 |
sfx_prompt = parts[0]
|
| 170 |
-
duration = float(parts[1]
|
| 171 |
|
| 172 |
sfx_prompts_text.append(f"{i+1}. {sfx_prompt} ({duration}s)")
|
| 173 |
|
|
|
|
| 151 |
|
| 152 |
# Clean Llama responses (your logic, made more robust)
|
| 153 |
prompts = response_text.splitlines()
|
| 154 |
+
fixed_prompts = [p for p in prompts if p and ";" in p] # Keep only valid, non-empty lines with a separator
|
| 155 |
+
|
| 156 |
if not fixed_prompts:
|
| 157 |
+
return transcript, "Llama did not return any valid prompts", []
|
| 158 |
|
| 159 |
# --- Step 3: ElevenLabs Audio Generation ---
|
| 160 |
output_audio_files = []
|
|
|
|
| 162 |
|
| 163 |
for i, line in enumerate(fixed_prompts):
|
| 164 |
try:
|
| 165 |
+
parts = line.split(";")
|
| 166 |
if len(parts) < 2:
|
| 167 |
continue # Skip malformed lines
|
| 168 |
|
| 169 |
sfx_prompt = parts[0]
|
| 170 |
+
duration = float(parts[1])
|
| 171 |
|
| 172 |
sfx_prompts_text.append(f"{i+1}. {sfx_prompt} ({duration}s)")
|
| 173 |
|