-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudio_slice.py
More file actions
22 lines (14 loc) · 768 Bytes
/
Audio_slice.py
File metadata and controls
22 lines (14 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# pip install pydub
# Also make sure ffmpeg is installed
# For ubuntu use "sudo apt install ffmpeg"
# For windows go to "https://www.ffmpeg.org/download.html" link download ffmpeg and update your environment path with ffmpeg/bin
from pydub import AudioSegment
from pydub.utils import make_chunks
audio_file_name = "Make some noise! DJI FPV Drone vs Mavic Air 2, 2 ProZoom & Mini - Noise & speed comparison"
newAudio = AudioSegment.from_file(audio_file_name + ".mp4", "mp4")
chunk_length_ms = 10 * 1000 # pydub calculates in millisec (10 sec)
chunks = make_chunks(newAudio, chunk_length_ms)
for i, chunk in enumerate(chunks):
chunk_name = "{0}{1}.wav".format(audio_file_name, i)
print("exporting", chunk_name)
chunk.export(chunk_name, format="wav")