32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import logging
|
|
logging.basicConfig(format="%(asctime)s/%(levelname)s: [%(module)s] %(message)s", level=logging.INFO)
|
|
|
|
import multiprocessing
|
|
import multiprocessing.process
|
|
import dataset
|
|
import audiopreprocessing
|
|
from pathlib import Path
|
|
|
|
def copy_worker(origin_queue, target_queue):
|
|
p = origin_queue.get()
|
|
logging.info(f"Processing: {p}")
|
|
l = audiopreprocessing.load_preprocessed_audio(p, 32000, True)
|
|
print("Preprocess complete, putting it into queue")
|
|
target_queue.put(l) # Even on a small scale test, the process will always hang here
|
|
|
|
if __name__ == "__main__":
|
|
audio_path_queue = multiprocessing.Queue()
|
|
audio_queue = multiprocessing.Queue()
|
|
|
|
rand_paths = dataset.random_audio_chunk(1)
|
|
for p in rand_paths:
|
|
audio_path_queue.put(p)
|
|
|
|
print("Files queued")
|
|
|
|
processes = [multiprocessing.Process(target=copy_worker, args=(audio_path_queue, audio_queue)) for _ in range(1)]
|
|
for p in processes: p.start()
|
|
for p in processes: p.join()
|
|
|
|
print("Joined")
|
|
#for _ in range(1): print(audio_queue.get()) |