mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-24 04:21:12 +00:00
Add Slicing Audio Python script-Dishant
This commit is contained in:
parent
785e930c62
commit
e876567f27
23
scripts/sliceAudio_mp3/README.md
Normal file
23
scripts/sliceAudio_mp3/README.md
Normal file
|
@ -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
|
||||||
|
|
28
scripts/sliceAudio_mp3/slicingAudio.py
Normal file
28
scripts/sliceAudio_mp3/slicingAudio.py
Normal 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
|
Loading…
Reference in New Issue
Block a user