-
Notifications
You must be signed in to change notification settings - Fork 3
/
convertAudio.py
44 lines (33 loc) · 1.02 KB
/
convertAudio.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
import glob, os, subprocess
def convertDir(inDir, outDir):
for path in glob.glob(os.path.join(inDir, "*.ACM")):
basename = os.path.splitext(os.path.basename(path))[0]
result = basename.lower() + ".wav" # output path of acm2wav
outpath = os.path.join(outDir, result)
print(path)
#print(basename)
# convert to wav
#os.system("acm2wav %s" % path)
subprocess.call(["acm2wav", path], stdout=subprocess.PIPE)
if not os.path.exists(result):
print("result file (%s) not found!" % result)
#break
elif not os.path.exists(outpath):
os.rename(result, outpath)
def main():
if not os.path.exists("acm2wav.exe"):
print("need acm2wav.exe")
return
if not os.path.exists("SFX"):
print("need SFX/")
return
if not os.path.exists("audio"):
os.mkdir("audio")
if not os.path.exists("audio/sfx"):
os.mkdir("audio/sfx")
if not os.path.exists("audio/music"):
os.mkdir("audio/music")
convertDir("SFX", "audio/sfx")
convertDir("sound/music", "audio/music")
print("done!")
if __name__ == '__main__': main()