Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Rongjiehuang committed Dec 12, 2022
1 parent 26cefd3 commit 2979dd2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
5 changes: 4 additions & 1 deletion data_gen/tts/base_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def process_wav(item_name, wav_fn, processed_dir, wav_processed_tmp, preprocess_
input_fn, sr, output_fn_for_align = outputs
else:
input_fn, sr = outputs
return input_fn, output_fn_for_align
if output_fn_for_align is None:
return input_fn, input_fn
else:
return input_fn, output_fn_for_align
else:
return wav_fn, wav_fn

Expand Down
2 changes: 1 addition & 1 deletion modules/GenerSpeech/config/generspeech.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ preprocess_args:
mfa_group_shuffle: false
mfa_offset: 0.02
# wav processors
wav_processors: [sox_resample]
wav_processors: []
save_sil_mask: true
vad_max_silence_length: 12

Expand Down
24 changes: 22 additions & 2 deletions utils/multiprocess_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from tqdm import tqdm


def chunked_worker(worker_id, map_func, args, results_queue=None, init_ctx_func=None):
def chunked_worker_binarize(worker_id, map_func, args, results_queue=None, init_ctx_func=None):
ctx = init_ctx_func(worker_id) if init_ctx_func is not None else None
for job_idx, arg in args:
try:
Expand All @@ -20,6 +20,25 @@ def chunked_worker(worker_id, map_func, args, results_queue=None, init_ctx_func=
results_queue.put((job_idx, None))


def chunked_worker(worker_id, args_queue=None, results_queue=None, init_ctx_func=None):
ctx = init_ctx_func(worker_id) if init_ctx_func is not None else None
while True:
args = args_queue.get()
if args == '<KILL>':
return
job_idx, map_func, arg = args
try:
map_func_ = partial(map_func, ctx=ctx) if ctx is not None else map_func
if isinstance(arg, dict):
res = map_func_(**arg)
elif isinstance(arg, (list, tuple)):
res = map_func_(*arg)
else:
res = map_func_(arg)
results_queue.put((job_idx, res))
except:
traceback.print_exc()
results_queue.put((job_idx, None))

class MultiprocessManager:
def __init__(self, num_workers=None, init_ctx_func=None, multithread=False):
Expand Down Expand Up @@ -102,6 +121,7 @@ def multiprocess_run(map_func, args, num_workers=None, ordered=True, init_ctx_fu
yield res



def chunked_multiprocess_run(
map_func, args, num_workers=None, ordered=True,
init_ctx_func=None, q_max_size=1000, multithread=False):
Expand All @@ -125,7 +145,7 @@ def chunked_multiprocess_run(
workers = []
for i in range(num_workers):
args_worker = args[i::num_workers]
p = Process(target=chunked_worker, args=(
p = Process(target=chunked_worker_binarize, args=(
i, map_func, args_worker, results_queues[i], init_ctx_func), daemon=True)
workers.append(p)
p.start()
Expand Down

0 comments on commit 2979dd2

Please sign in to comment.