From 67d8734b1e0981fb8f1e9866588ac70b7c592e6e Mon Sep 17 00:00:00 2001 From: Abinash Mahapatra <89697294+Abinash-bit@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:24:13 +0530 Subject: [PATCH] Trim_Audio --- Trim_Audio.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Trim_Audio.py diff --git a/Trim_Audio.py b/Trim_Audio.py new file mode 100644 index 0000000..26f72b1 --- /dev/null +++ b/Trim_Audio.py @@ -0,0 +1,14 @@ +def trim_audio(input_file_path, output_file_path, start_time, end_time): + # Load the video file + audio = AudioSegment.from_wav(input_file_path) + # Trim the video + trimmed_audio = audio[start_time * 1000:end_time * 1000] + # Save the trimmed video + trimmed_audio.export(output_file_path, format="wav") + +# Example usage: +input_file_path = 'input.wav' +output_file_path = 'trimmed_output.wav' +start_time = 10 # in seconds +end_time = 20 # in seconds +trim_audio(input_file_path, output_file_path, start_time, end_time) \ No newline at end of file