Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import os
|
|
| 5 |
import subprocess
|
| 6 |
import uuid
|
| 7 |
import shutil
|
| 8 |
-
|
| 9 |
|
| 10 |
|
| 11 |
from huggingface_hub import snapshot_download, list_repo_files, hf_hub_download
|
|
@@ -237,27 +237,7 @@ 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 |
-
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,7 +247,7 @@ def run_pipeline(prompt_text, steps, image_paths, audio_file_path, max_duration
|
|
| 267 |
runner.inference_loop(
|
| 268 |
prompt_text,
|
| 269 |
img_paths,
|
| 270 |
-
|
| 271 |
output_dir,
|
| 272 |
filename,
|
| 273 |
inference_mode,
|
|
@@ -412,7 +392,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 412 |
10,
|
| 413 |
["./examples/art.png"],
|
| 414 |
"./examples/art.wav",
|
| 415 |
-
|
| 416 |
],
|
| 417 |
|
| 418 |
[
|
|
@@ -428,7 +408,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 428 |
40,
|
| 429 |
["./examples/amber.png", "./examples/jacket.png"],
|
| 430 |
"./examples/fictional.wav",
|
| 431 |
-
70,
|
| 432 |
],
|
| 433 |
|
| 434 |
],
|
|
@@ -450,4 +430,4 @@ with gr.Blocks(css=css) as demo:
|
|
| 450 |
if __name__ == "__main__":
|
| 451 |
demo.unload(cleanup)
|
| 452 |
demo.queue()
|
| 453 |
-
demo.launch(ssr_mode=False)
|
|
|
|
| 5 |
import subprocess
|
| 6 |
import uuid
|
| 7 |
import shutil
|
| 8 |
+
|
| 9 |
|
| 10 |
|
| 11 |
from huggingface_hub import snapshot_download, list_repo_files, hf_hub_download
|
|
|
|
| 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 |
runner.inference_loop(
|
| 248 |
prompt_text,
|
| 249 |
img_paths,
|
| 250 |
+
audio_path,
|
| 251 |
output_dir,
|
| 252 |
filename,
|
| 253 |
inference_mode,
|
|
|
|
| 392 |
10,
|
| 393 |
["./examples/art.png"],
|
| 394 |
"./examples/art.wav",
|
| 395 |
+
45,
|
| 396 |
],
|
| 397 |
|
| 398 |
[
|
|
|
|
| 408 |
40,
|
| 409 |
["./examples/amber.png", "./examples/jacket.png"],
|
| 410 |
"./examples/fictional.wav",
|
| 411 |
+
70,
|
| 412 |
],
|
| 413 |
|
| 414 |
],
|
|
|
|
| 430 |
if __name__ == "__main__":
|
| 431 |
demo.unload(cleanup)
|
| 432 |
demo.queue()
|
| 433 |
+
demo.launch(ssr_mode=False)
|