我一直在尝试运行 UBM.EM_Split() 功能。我创建了一个功能文件 feat.h5 (3.8 MB),它存储了24个音频文件的功能。我尝试使用此功能文件作为函数中feature_list参数的输入。但是,代码已运行超过72小时,没有输出或响应。仔细观察,代码被冻结的代码行如下:
# Wait for all the tasks to finish
queue_in.join()
这是我使用的代码(它基于sidekit网站上的UBM教程):
import sidekit
import os
#Read all the files in the directory
all_files = os.listdir("D:/DatabaseFiles/Sidekit/")
extractor = sidekit.FeaturesExtractor(audio_filename_structure="D:/DatabaseFiles/Sidekit/{}",
feature_filename_structure="D:/Sidekit/Trial/feat.h5",
sampling_frequency=16000,
lower_frequency=200,
higher_frequency=3800,
filter_bank="log",
filter_bank_size=24,
window_size=0.04,
shift=0.01,
ceps_number=20,
vad="snr",
snr=40,
pre_emphasis=0.97,
save_param=["vad", "energy", "cep", "fb"],
keep_all_features=True)
#To iterate through a whole list
for x in all_files:
extractor.save(x)
server = sidekit.FeaturesServer(feature_filename_structure="D:/Sidekit/Trial/feat.h5",
sources=None,
dataset_list=["vad", "energy", "cep", "fb"],
feat_norm="cmvn",
global_cmvn=None,
dct_pca=False,
dct_pca_config=None,
sdc=False,
sdc_config=None,
delta=True,
double_delta=True,
delta_filter=None,
context=None,
traps_dct_nb=None,
rasta=True,
keep_all_features=True)
ubm = sidekit.Mixture()
ubm.EM_split(features_server=server,
feature_list="D:/Sidekit/Trial/feat.h5",
distrib_nb=32,
iterations=(1, 2, 2, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8),
num_thread=10,
save_partial=True,
ceil_cov=10,
floor_cov=1e-2
)
我还根据从有经验的用户收到的建议尝试了以下函数调用( feature_list = all_files )。但是,这也没有解决问题。
ubm.EM_split(features_server=server,
feature_list=all_files,
distrib_nb=32,
iterations=(1, 2, 2, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8),
num_thread=10,
save_partial=True,
ceil_cov=10,
floor_cov=1e-2
)
我在Windows和Linux环境中都遇到了同样的问题。两个系统都有32 GB RAM,mpi设置为真。
你知道我做错了什么吗?对于包含24个音频文件(feat.h5为3.8 MB)的h5文件是否需要这么长时间?
答案 0 :(得分:4)
我对你的代码进行了一些调整,并设法使用我作为任意训练数据说谎的一些wav文件来训练UBM。
在编辑数据的目录路径后,您的代码成功提取了这些功能。当运行EM_split部件时,它失败了,可能是因为你的错误相同。
问题很简单,与功能提取器生成的HDF5文件的内部目录结构有关。似乎FeatureServer对象在解释文件列表时不是很灵活。因此,一种选择是编辑源代码(features_server.py)。但是,最简单的解决方法是将功能文件列表更改为FeatureServer可以解释的内容。
特征提取:
import sidekit
import os
import numpy as np
# Setting parameters
nbThread = 4 # change to desired number of threads
nbDistrib = 32 # change to desired final number of Gaussian distributions
base_dir = "./Database/sidekit_data"
wav_dir = os.path.join(base_dir, "wav")
feature_dir = os.path.join(base_dir, "feat")
# Prepare file lists
all_files = os.listdir(wav_dir)
show_list = np.unique(np.hstack([all_files]))
channel_list = np.zeros_like(show_list, dtype = int)
# 1: Feature extraction
extractor = sidekit.FeaturesExtractor(audio_filename_structure=os.path.join(wav_dir, "{}"),
feature_filename_structure=os.path.join(feature_dir, "{}.h5"),
sampling_frequency=16000,
lower_frequency=200,
higher_frequency=3800,
filter_bank="log",
filter_bank_size=24,
window_size=0.04,
shift=0.01,
ceps_number=20,
vad="snr",
snr=40,
pre_emphasis=0.97,
save_param=["vad", "energy", "cep", "fb"],
keep_all_features=True)
extractor.save_list(show_list=show_list,
channel_list=channel_list,
num_thread=nbThread)
现在,训练数据中的每个wav文件都有一个HDF5文件。不是很优雅,因为你可以只用一个管理,但它的工作原理。函数extractor.save_list()很有用,因为它允许运行多个进程,这将大大加快特征提取。
我们现在可以训练UBM:
# 2: UBM Training
ubm_list = os.listdir(os.path.join(base_dir, "feat")) # make sure this directory only contains the feature files extracted above
for i in range(len(ubm_list)):
ubm_list[i] = ubm_list[i].split(".h5")[0]
server = sidekit.FeaturesServer(feature_filename_structure=os.path.join(feat_dir, "{}.h5"),
sources=None,
dataset_list=["vad", "energy", "cep", "fb"],
feat_norm="cmvn",
global_cmvn=None,
dct_pca=False,
dct_pca_config=None,
sdc=False,
sdc_config=None,
delta=True,
double_delta=True,
delta_filter=None,
context=None,
traps_dct_nb=None,
rasta=True,
keep_all_features=True)
ubm = sidekit.Mixture()
ubm.EM_split(features_server=server,
feature_list=ubm_list,
distrib_nb=nbDistrib,
iterations=(1, 2, 2, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8),
num_thread=nbThread,
save_partial=True,
ceil_cov=10,
floor_cov=1e-2
)
我建议在最后添加以下行以保存您的UBM:
ubm_dir = os.path.join(base_dir, "ubm")
ubm.write(os.path.join(ubm_dir, "ubm_{}.h5".format(nbDistrib)))
它就是!如果这对您有用,请告诉我。特征提取和模型训练不到10分钟。 (Ubuntu 14.04,Python 3.5.3,Sidekit v 1.2,30分钟的训练数据,16kHz采样率)。