-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudioSplitter.py
More file actions
36 lines (28 loc) · 821 Bytes
/
Copy pathaudioSplitter.py
File metadata and controls
36 lines (28 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from pydub import AudioSegment
def audio_convert(file_name):
sound = AudioSegment.from_mp3(file_name)
length=len(sound)
remaining_length=20000
if remaining_length>length:
remaining_length=length
initial=0
final=remaining_length
counter=0
file_small=False
while True:
if remaining_length>length:
if counter==0:
file_small=True
break
try:
sound_half=sound[initial:final]
except:
sound_half=sound[initial:length]
initial=remaining_length
remaining_length+=20000
final=remaining_length
sound_half.export("//home//pi//Desktop//RasPA//audio_split//"+str(counter)+".wav", format="wav")
counter+=1
if file_small==True:
sound_half=sound[0:length]
sound_half.export("//home//pi//Desktop//RasPA//audio_split//"+str(0)+".wav", format="wav")