Merge pull request #112 from Dishant10/dishant-python-script

Dishant python script
This commit is contained in:
Advaita Saha 2022-10-04 14:11:39 +05:30 committed by GitHub
commit 819f6d39cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# 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

View File

@ -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