python 获取语音数据集 幅值的最大值

# coding=utf-8
import os
import wavio

files_name = os.listdir('./datasets/100-Nonspeech/')   # 返回文件或文件夹的名字
# print(files_name)
# os.system("pause")

max_data = []
max_set =1
for i in range(100):
    wav_s = wavio.read("./datasets/100-Nonspeech/" + files_name[i])
    # Wav(data.shape=(80000, 1), data.dtype=int16, rate=20000, sampwidth=2)
    max_wav = max(wav_s.data)
    max_data.append(max_wav)

    if max_wav > max_set:
        max_set = max_wav

with open("./datasets/data.txt","w") as f:
     for j in range(100):
        f.writelines(str(max_data[j]))
        # print(max_data[j])

print(max_set)      # 100种环境噪声幅值:[27307]

结果:

python 获取语音数据集 幅值的最大值_第1张图片

 

你可能感兴趣的:(Python学习,语音分离)