我试图在for循环中提取大约2000个音频样本的频率,并将它们全部保存在一个npz文件中。
for audio_file in value:
audio_file_path = os.path.join(dir_path, key, audio_file)
#get frequency from audio signal from sampling rate as 16000
ys, sr = lb.core.load(audio_file_path, sr = 16000)
ys = np.array(ys, dtype = np.float)
#key is file name and ys is array
np.savez(key, ys)
答案 0 :(得分:0)
使用numpy savez时,首先应为它提供保存路径和将要创建的文件的名称,然后是要保存的阵列,请参见下文”
np.savez("path to dir/file_name", key, ys)
请参阅here
告诉我您的代码是否还有问题?