如何将特征提取另存为.wav文件中的元组到excel?

时间:2019-06-15 08:19:18

标签: python-3.x csv wav feature-extraction

我正在使用以下代码,但是我的fbank_feat是元组,并且我无法在Excel文件中保存特征提取(第28行-df)。

from pathlib import Path
from python_speech_features import fbank
import scipy.io.wavfile as wavfile
import numpy as np
import pandas as pd


path = Path('/home/narges/dataset/dataset-CV-16kHz-128kbps/train/').glob('**/*.wav')
wavs = [str(wavf) for wavf in path if wavf.is_file()]
wavs.sort()
print(wavs)

number_of_files=len(wavs)
spk_ID = [wavs[i].upper() for i in range(number_of_files)]
spk_sent = [wavs[i] for i in range(number_of_files)]


for i in range(number_of_files):
    (rate, sig) = wavfile.read(wavs[i])



fbank_feat=fbank(sig, rate, winlen=0.06, winstep=0.01, nfilt=26, nfft=512, lowfreq=0, highfreq=rate/2, preemph=0.97, winfunc=np.hamming)
print(fbank_feat)

df = pd.DataFrame('fbank_feat')
writer = pd.ExcelWriter('dataset.xlsx', engine='xlsxWriter')
df.to_excel(writer, 'feat1')
writer.save()

0 个答案:

没有答案