From e876567f2701002fcbbe3d5d40cbd1b99ffb18eb Mon Sep 17 00:00:00 2001 From: Dishant Nagpal Date: Tue, 4 Oct 2022 13:46:12 +0530 Subject: [PATCH 1/2] Add Slicing Audio Python script-Dishant --- scripts/sliceAudio_mp3/README.md | 23 +++++++++++++++++++++ scripts/sliceAudio_mp3/slicingAudio.py | 28 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 scripts/sliceAudio_mp3/README.md create mode 100644 scripts/sliceAudio_mp3/slicingAudio.py diff --git a/scripts/sliceAudio_mp3/README.md b/scripts/sliceAudio_mp3/README.md new file mode 100644 index 0000000..ab9dc59 --- /dev/null +++ b/scripts/sliceAudio_mp3/README.md @@ -0,0 +1,23 @@ +# Slice Audio from any mp3 file + +We all want only a portion form a particular audio file. This python scrip does the same for you in few very easy steps. + +Only have to enter few things to get started and the rest is magic. + +What all do you have to enter? + +1.) Your file Path - Where your initial audio file(mp3) is located. +2.) Your export Path - Where you want to save your resultant sliced audio file to be saved. +3.) Start Minute - From what minute into the audio you want to slice from +4.) Start Second - From what second after the start minute you want to slice from +5.) End Minute - Till what minute you want the final audio to be. +6.) End Second - Till what second of the End minute you want to final audio to be. + +# Requirements + +Clone Repo +You need to intall pydub library for this script to run. +You can use pip - pip install pydub +More information on pydub here - https://pypi.org/project/pydub/ +Use the python script slicingAudio.py + diff --git a/scripts/sliceAudio_mp3/slicingAudio.py b/scripts/sliceAudio_mp3/slicingAudio.py new file mode 100644 index 0000000..87c6319 --- /dev/null +++ b/scripts/sliceAudio_mp3/slicingAudio.py @@ -0,0 +1,28 @@ +from pydub import AudioSegment + +#Example File path +#filePath = "/Users/dishantnagpal/Desktop/python/exampleAudio.mp3" + +#Example Exoprt Path +#exportPath = "/Users/dishantnagpal/Desktop/python/newPortion-1.mp3" + +filePath = input("Enter your path to the audio file") #Enter your file path +exportPath = input("Enter the path you want to save the file at") #Enter export Path + +sound = AudioSegment.from_mp3(filePath) #Making an executable audio file from the given path + +startMin = int(input('Enter Start Minute ')) +startSecond = int(input('Enter Start Second ')) + +endMin = int(input('Enter End Minute ')) +endSecond = int(input('Enter End Second ')) + + +startTime = startMin*60*1000+startSecond*1000 +endTime = endMin*60*1000+endSecond*1000 + + +extract = sound[startTime:endTime] #Extracting sliced Audio + + +extract.export(exportPath, format="mp3") #Saving the final audio file at your export path From d1a6cf5ce21077efd7488cafb6f755c2aae2a8b4 Mon Sep 17 00:00:00 2001 From: Dishant Nagpal Date: Tue, 4 Oct 2022 13:50:32 +0530 Subject: [PATCH 2/2] Update README.md Fixed Spacing issue --- scripts/sliceAudio_mp3/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/sliceAudio_mp3/README.md b/scripts/sliceAudio_mp3/README.md index ab9dc59..a7321ed 100644 --- a/scripts/sliceAudio_mp3/README.md +++ b/scripts/sliceAudio_mp3/README.md @@ -7,10 +7,15 @@ Only have to enter few things to get started and the rest is magic. What all do you have to enter? 1.) Your file Path - Where your initial audio file(mp3) is located. + 2.) Your export Path - Where you want to save your resultant sliced audio file to be saved. + 3.) Start Minute - From what minute into the audio you want to slice from + 4.) Start Second - From what second after the start minute you want to slice from + 5.) End Minute - Till what minute you want the final audio to be. + 6.) End Second - Till what second of the End minute you want to final audio to be. # Requirements