个人数据集的声纹识别

问题描述

create_data.py文件中用的是zhvoice数据集,那么我们应该怎么修改程序才能识别我们自己的数据集呢?
或者说我们的数据集要怎么创建才能符合代码的要求?
以及数据集的语音数量是否有要求?

问题相关代码,请勿粘贴截图

def get_data_list(infodata_path, list_path, zhvoice_path):
with open(infodata_path, 'r', encoding='utf-8') as f:
lines = f.readlines()

f_train = open(os.path.join(list_path, 'train_list.txt'), 'w')
f_test = open(os.path.join(list_path, 'test_list.txt'), 'w')

sound_sum = 0
speakers = []
speakers_dict = {}
for line in tqdm(lines):
    line = json.loads(line.replace('\n', ''))
    duration_ms = line['duration_ms']
    if duration_ms < 1300:
        continue
    speaker = line['speaker']
    if speaker not in speakers:
        speakers_dict[speaker] = len(speakers)
        speakers.append(speaker)
    label = speakers_dict[speaker]
    sound_path = os.path.join(zhvoice_path, line['index'])
    save_path = "%s.wav" % sound_path[:-4]
    if not os.path.exists(save_path):
        try:
            wav = AudioSegment.from_mp3(sound_path)
            wav.export(save_path, format="wav")
            os.remove(sound_path)
        except Exception as e:
            print('数据出错:%s, 信息:%s' % (sound_path, e))
            continue
    if sound_sum % 200 == 0:
        f_test.write('%s\t%d\n' % (save_path.replace('\\', '/'), label))
    else:
        f_train.write('%s\t%d\n' % (save_path.replace('\\', '/'), label))
    sound_sum += 1

f_test.close()
f_train.close()
运行结果及报错内容

使用zhvoice数据包时,显示未找到文件
自己的数据集还不知道怎么使用

我的解答思路和尝试过的方法

将自己的数据集直接替换到zhvoice文件夹内

我想要达到的结果

能够用自己的数据集进行训练并识别自己的声音

应该是你没有解压数据导致找不到数据的。
你下载的这个数据只要全部解答里面的文件才行。
自己的数据集的话,按照那个数据列表的格式生成就好。