Spaces:
Running
on
Zero
Running
on
Zero
alex
commited on
Commit
·
d508b4f
1
Parent(s):
53a1d00
silence
Browse files
app.py
CHANGED
|
@@ -237,7 +237,27 @@ def run_pipeline(prompt_text, steps, image_paths, audio_file_path, max_duration
|
|
| 237 |
# Prepare output
|
| 238 |
output_dir = os.path.join(os.environ["PROCESSED_RESULTS"], session_id)
|
| 239 |
os.makedirs(output_dir, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
# Random filename
|
| 242 |
filename = f"gen_{uuid.uuid4().hex[:10]}"
|
| 243 |
width, height = 832, 480
|
|
@@ -247,7 +267,7 @@ def run_pipeline(prompt_text, steps, image_paths, audio_file_path, max_duration
|
|
| 247 |
runner.inference_loop(
|
| 248 |
prompt_text,
|
| 249 |
img_paths,
|
| 250 |
-
|
| 251 |
output_dir,
|
| 252 |
filename,
|
| 253 |
inference_mode,
|
|
|
|
| 237 |
# Prepare output
|
| 238 |
output_dir = os.path.join(os.environ["PROCESSED_RESULTS"], session_id)
|
| 239 |
os.makedirs(output_dir, exist_ok=True)
|
| 240 |
+
def add_silence_to_audio_ffmpeg(audio_path, tmp_audio_path, silence_duration_s=0.5):
|
| 241 |
+
|
| 242 |
+
command = [
|
| 243 |
+
'ffmpeg',
|
| 244 |
+
'-i', audio_path,
|
| 245 |
+
'-f', 'lavfi',
|
| 246 |
+
'-t', str(silence_duration_s),
|
| 247 |
+
'-i', 'anullsrc=r=16000:cl=stereo',
|
| 248 |
+
'-filter_complex', '[1][0]concat=n=2:v=0:a=1[out]',
|
| 249 |
+
'-map', '[out]',
|
| 250 |
+
'-y', tmp_audio_path,
|
| 251 |
+
'-loglevel', 'quiet'
|
| 252 |
+
]
|
| 253 |
+
|
| 254 |
+
subprocess.run(command, check=True)
|
| 255 |
|
| 256 |
+
|
| 257 |
+
tmp_audio_path = os.path.join(output_dir, "tmp_audio.wav")
|
| 258 |
+
|
| 259 |
+
add_silence_to_audio_ffmpeg(audio_path, tmp_audio_path)
|
| 260 |
+
|
| 261 |
# Random filename
|
| 262 |
filename = f"gen_{uuid.uuid4().hex[:10]}"
|
| 263 |
width, height = 832, 480
|
|
|
|
| 267 |
runner.inference_loop(
|
| 268 |
prompt_text,
|
| 269 |
img_paths,
|
| 270 |
+
tmp_audio_path,
|
| 271 |
output_dir,
|
| 272 |
filename,
|
| 273 |
inference_mode,
|