From 9da1a87f3025ea3b9c40427dd9d1a3aab1940e7b Mon Sep 17 00:00:00 2001 From: rany Date: Thu, 10 Mar 2022 15:49:20 +0200 Subject: [PATCH] only speed up, don't slow down --- examples/02_subrip_to_mp3.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/examples/02_subrip_to_mp3.py b/examples/02_subrip_to_mp3.py index 3670239..b5714aa 100755 --- a/examples/02_subrip_to_mp3.py +++ b/examples/02_subrip_to_mp3.py @@ -46,21 +46,24 @@ def ensure_audio_length(in_file, out_file, length): atempo = 0.5 elif atempo > 100: atempo = 100 - process = subprocess.call( - [ - "ffmpeg", - "-y", - "-i", - in_file, - "-filter:a", - f"atempo={atempo}", - out_file, - ], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - ) - if process != 0: - raise Exception("ffmpeg failed") + if atempo > 1: + process = subprocess.call( + [ + "ffmpeg", + "-y", + "-i", + in_file, + "-filter:a", + f"atempo={atempo}", + out_file, + ], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + if process != 0: + raise Exception("ffmpeg failed") + else: + shutil.copyfile(in_file, out_file) async def _main(srt_data, voice_name, out_file):