1
0
mirror of https://github.com/Escartem/AnimeWwise.git synced 2026-06-05 07:50:23 +08:00

wip stuff

This commit is contained in:
Escartem
2026-01-17 15:13:54 -05:00
parent bc84b53fdc
commit 0dc6730c97

View File

@@ -6,9 +6,11 @@ import tempfile
import wavescan import wavescan
import platform import platform
import subprocess import subprocess
import multiprocessing
from mapper import Mapper from mapper import Mapper
from allocator import Allocator from allocator import Allocator
from filereader import FileReader from filereader import FileReader
from concurrent.futures import ThreadPoolExecutor, as_completed
cwd = os.getcwd() cwd = os.getcwd()
path = lambda *args: os.path.join(*args) path = lambda *args: os.path.join(*args)
@@ -332,27 +334,59 @@ class WwiseExtract:
self.allocator.free_mem() self.allocator.free_mem()
def extract_wav(self, _input, files, output): def extract_wav(self, _input, files, output):
print(": Converting audio to wav") print(": Converting audio to wav (MAY TAKE A MINUTE FOR PROGRESS BAR TO UPDATE)")
pos = 0
for file in files:
pos += 1
self.update_progress(pos, len(files), 2)
filename = f'{os.path.basename(file).split(".")[0]}.wav' max_workers = min(8, multiprocessing.cpu_count())
filepath = path(output, os.path.dirname(file), filename)
os.makedirs(os.path.dirname(filepath), exist_ok=True) with ThreadPoolExecutor(max_workers=max_workers) as executor:
futures = []
args = [ for pos, file in enumerate(files, 1):
path(cwd, "tools/vgmstream/vgmstream-cli.exe"), filename = f'{os.path.basename(file).split(".")[0]}.wav'
"-o", filepath = path(output, os.path.dirname(file), filename)
filepath, os.makedirs(os.path.dirname(filepath), exist_ok=True)
path(_input, file)
]
if platform.system() != "Windows": args = [
args.insert(0, "wine") path(cwd, "tools/vgmstream/vgmstream-cli.exe"),
"-o",
filepath,
path(_input, file)
]
call(args) if platform.system() != "Windows":
args.insert(0, "wine")
futures.append(executor.submit(call, args))
# self.update_progress(pos, len(files), 2)
done = 0
total = len(futures)
for _ in as_completed(futures):
# f.result()
done += 1
self.update_progress(done, total, 2)
# pos = 0
# for file in files:
# pos += 1
# self.update_progress(pos, len(files), 2)
# filename = f'{os.path.basename(file).split(".")[0]}.wav'
# filepath = path(output, os.path.dirname(file), filename)
# os.makedirs(os.path.dirname(filepath), exist_ok=True)
# args = [
# path(cwd, "tools/vgmstream/vgmstream-cli.exe"),
# "-o",
# filepath,
# path(_input, file)
# ]
# if platform.system() != "Windows":
# args.insert(0, "wine")
# call(args)
def extract_ffmpeg(self, _input, files, output, _format): def extract_ffmpeg(self, _input, files, output, _format):
print(f": Converting audio to {_format}") print(f": Converting audio to {_format}")