Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -250,22 +250,24 @@ def run_pipeline(prompt_text, steps, image_paths, audio_file_path, max_duration
|
|
| 250 |
if audio_path:
|
| 251 |
|
| 252 |
def add_silence_to_audio_ffmpeg(audio_path, tmp_audio_path, silence_duration_s=0.5):
|
| 253 |
-
|
| 254 |
command = [
|
| 255 |
-
'ffmpeg',
|
| 256 |
-
'-i', audio_path,
|
| 257 |
-
'-f', 'lavfi',
|
| 258 |
-
'-t', str(silence_duration_s),
|
| 259 |
-
'-i', 'anullsrc=r=16000:cl=
|
| 260 |
-
'-filter_complex',
|
| 261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
'-y', tmp_audio_path,
|
| 263 |
-
'-loglevel', '
|
| 264 |
]
|
| 265 |
-
|
| 266 |
subprocess.run(command, check=True)
|
| 267 |
|
| 268 |
-
|
| 269 |
tmp_audio_path = os.path.join(output_dir, "tmp_audio.wav")
|
| 270 |
|
| 271 |
add_silence_to_audio_ffmpeg(audio_path, tmp_audio_path)
|
|
|
|
| 250 |
if audio_path:
|
| 251 |
|
| 252 |
def add_silence_to_audio_ffmpeg(audio_path, tmp_audio_path, silence_duration_s=0.5):
|
|
|
|
| 253 |
command = [
|
| 254 |
+
'ffmpeg',
|
| 255 |
+
'-i', audio_path,
|
| 256 |
+
'-f', 'lavfi',
|
| 257 |
+
'-t', str(silence_duration_s),
|
| 258 |
+
'-i', 'anullsrc=r=16000:cl=mono', # generate 16 kHz mono
|
| 259 |
+
'-filter_complex',
|
| 260 |
+
(
|
| 261 |
+
'[0:a]aresample=16000,pan=mono|c0=c0[a0];'
|
| 262 |
+
'[1:a]aresample=16000,pan=mono|c0=c0[a1];'
|
| 263 |
+
'[a1][a0]concat=n=2:v=0:a=1[out]'
|
| 264 |
+
),
|
| 265 |
+
'-map', '[out]',
|
| 266 |
'-y', tmp_audio_path,
|
| 267 |
+
'-loglevel', 'error'
|
| 268 |
]
|
|
|
|
| 269 |
subprocess.run(command, check=True)
|
| 270 |
|
|
|
|
| 271 |
tmp_audio_path = os.path.join(output_dir, "tmp_audio.wav")
|
| 272 |
|
| 273 |
add_silence_to_audio_ffmpeg(audio_path, tmp_audio_path)
|