在使用附带工具包的UBM说话人适应过程中出现错误

时间:2019-04-17 09:06:34

标签: python machine-learning speech-recognition voice-recognition sidekit

我已经训练了UBM模型,现在当我遇到以下错误时,我正在尝试实现说话人自适应。

  

例外:show enroll / something.wav不在HDF5文件中

我在文件“ feat”下有两个文件“ enroll”和“ test”,分别包含用于训练和测试的功能(.h5),并且我的enroll_idmap仅通过用于训练的音频(.wav)生成。而且,我的wav文件和feat文件是分开的。我认为我遇到了idmap问题。 “ enroll / something.wav”是我的enroll_idmap的rightid,但是“ HDF5文件”指的是什么?

谁能告诉我这个错误的含义以及如何解决?

这是我的enroll_idmap的代码

def __init__(self):
    BASE_DIR = "./Database/sidekit_data"
    self.AUDIO_DIR = os.path.join(BASE_DIR, "audio")
    self.FEATURE_DIR = os.path.join(BASE_DIR, "feat")
    self.TASK_DIR = os.path.join(BASE_DIR, "task")    

def create_idMap(self, group):
    # Make enrollment (IdMap) file list
    group_dir = os.path.join(self.AUDIO_DIR, group) # enrollment data directory
    group_files = os.listdir(group_dir)
    group_models = [files.split('_')[0] for files in group_files] # list of model IDs
    group_segments = [group+"/"+f for f in group_files]

    # Generate IdMap
    group_idmap = sidekit.IdMap()
    group_idmap.leftids = np.asarray(group_models)
    group_idmap.rightids = np.asarray(group_segments)
    group_idmap.start = np.empty(group_idmap.rightids.shape, '|O')
    group_idmap.stop = np.empty(group_idmap.rightids.shape, '|O')
    if group_idmap.validate():
        group_idmap.write(os.path.join(self.TASK_DIR, group+'_idmap.h5'))
    else:
        raise RuntimeError('Problems with creating idMap file')

然后,我得到带有以下内容的enroll_idmap和test_idmap:

create_idMap("enroll")
create_idMap("test")

这是说话者适应的代码,上面的错误在执行enroll_stat.accumulate_stat(…)时出现:

BASE_DIR = "./Database/sidekit_data"

enroll_idmap = sidekit.IdMap.read(os.path.join(BASE_DIR, "task", "enroll_idmap.h5"))

ubm = sidekit.Mixture()    
model_name = "ubm_{}.h5".format(NUM_GUASSIANS)    
ubm.read(os.path.join(BASE_DIR, "ubm", model_name))

server_eval = sidekit.FeaturesServer(feature_filename_structure="./Database/sidekit_data/feat/{}.h5",
                                     ...
                                     ...)

print("Compute the sufficient statistics")

enroll_stat.accumulate_stat(ubm=ubm,
                        feature_server=server_eval,
                        seg_indices=range(enroll_stat.segset.shape[0]),
                        num_thread=nbThread
                        )

这似乎不是什么大问题,但是它让我停了几天,请帮忙。

1 个答案:

答案 0 :(得分:1)

我最终通过更改培训和测试功能的路径,使其在“ BASEDIR”之外得以解决

server_eval = sidekit.FeaturesServer(feature_filename_structure="./enroll/{}.h5",
                                     ...)