-
Notifications
You must be signed in to change notification settings - Fork 1
/
mixing.py
executable file
·52 lines (36 loc) · 1.19 KB
/
mixing.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from fireplay import PlayItem, PlayList
from pydub import AudioSegment
import xml.etree.ElementTree as ElementTree
import codecs
def MixdownItems(items):
product=None
product_len = 0.0
for item in items:
try:
if item.PathName.endswith(".mp3"):
new = AudioSegment.from_mp3(item.PathName)
elif item.PathName.endswith(".wav"):
new = AudioSegment.from_wav(item.PathName)
else:
continue
except:
continue
if product == None:
product = new
else:
product.overlay(new, position=product_len)
product_len += float(item.Trajanje)
return product
encodings = ["utf-8", "windows-1250", "windows-1252"]
encoding = ""
for e in encodings:
try:
with codecs.open('smixana.xml', 'r', e) as file:
tree = ElementTree.fromstring(file.read())
encoding = e
except:
pass
#using fft to locate the good location in the start
#using markers to select the start and end of the news for
playitems = [PlayItem(item) for item in list(tree) if item.tag=="PlayItem"]
output = MixdownItems(playlistitems)