Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiprocessing to accelerate preprocess. #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions preprocess.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! python
# -*- coding: utf-8 -*-
# Author: kun
# @Time: 2019-07-23 14:26
# Author: kun, winlaic
# @Time: 2021-10-13 19:17


import librosa
Expand All @@ -11,6 +11,9 @@
from pprint import pprint
import librosa.display
import time
from multiprocessing import Pool
from tqdm import tqdm
from functools import partial


def load_wavs(wav_dir, sr):
Expand Down Expand Up @@ -53,23 +56,20 @@ def world_encode_spectral_envelop(sp, fs, dim=24):
return coded_sp


def world_encode_data(wave, fs, frame_period=5.0, coded_dim=24):
f0s = list()
timeaxes = list()
sps = list()
aps = list()
coded_sps = list()
for wav in wave:
f0, timeaxis, sp, ap = world_decompose(wav=wav,
def world_encode_single_data(wav, fs, frame_period, coded_dim):
f0, timeaxis, sp, ap = world_decompose(wav=wav,
fs=fs,
frame_period=frame_period)
coded_sp = world_encode_spectral_envelop(sp=sp, fs=fs, dim=coded_dim)
f0s.append(f0)
timeaxes.append(timeaxis)
sps.append(sp)
aps.append(ap)
coded_sps.append(coded_sp)
return f0s, timeaxes, sps, aps, coded_sps
coded_sp = world_encode_spectral_envelop(sp=sp, fs=fs, dim=coded_dim)
return f0, timeaxis, sp, ap, coded_sp

def world_encode_data(wave, fs, frame_period=5.0, coded_dim=24):
wrapped = partial(world_encode_single_data, fs=fs, frame_period=frame_period, coded_dim=coded_dim)
with Pool(16) as pool:
ret = list(tqdm(pool.imap(wrapped, wave), total=len(wave)))

return list(map(list, zip(*ret)))



def logf0_statistics(f0s):
Expand Down