【发布时间】:2020-07-22 17:21:43
【问题描述】:
我正在使用深度学习进行音频分类,我正在关注一个视频系列并停留在一个阶段。 以下代码是spyder中编写的代码:
import os
from tqdm import tqdm
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import wavfile
import python_speech_features
from python_speech_features import mfcc,logfbank
import librosa
def plot_signals(signals):
fig, axes = plt.subplots(nrows=2, ncols=5, sharex=False,
aharey=True, figsize=(20,5))
fig.suptitle('Time Series', size=16)
i=0
for x in range(2):
for y in range(5):
axes[x,y].set_title(list(signals.keys())[i])
axes[x.y].plot(list(signals.value())[i])
axes[x,y].get_xaxis().set_visible(False)
axes[x,y].get_yaxis().set_visible(False)
i+=1
def plot_fft(fft):
fig, axes = plt.subplots(nrows=2, ncols=5, sharex=False,
sharey=True, figsize=(20,5))
fig.suptitle('Fourier Transform', size=16)
i = 0
for x in range(2):
for y in range(5):
data=list(fft.value())[i]
Y, freq = data[0], data[1]
axes[x,y].set_title(list(fft.keys())[i])
axes[x.y].plot(freq, Y)
axes[x,y].get_xaxis().set_visible(False)
axes[x,y].get_yaxis().set_visible(False)
i+=1
def plot_fbank(fbank):
fig, axes = plt.subplots(nrows=2, ncols=5, sharex=False,
sharey=True, figsize=(20,5))
fig.suptitle('Filter Bank Coefficients', size = 16)
i = 0
for x in range(2):
for y in range(5):
axes[x,y].set_title(list(fbank.keys())[i])
axes[x.y].imshow(list(fbank.values())[i],
cmap='hot', interpolation='nearest')
axes[x,y].get_xaxis().set_visible(False)
axes[x,y].get_yaxis().set_visible(False)
i+=1
def plot_mfccs(mfccs):
fig, axes = plt.subplots(nrows=2, ncols=5, sharex=False,
sharey=True, figsize=(20,5))
fig.suptitle('Mel Frequency Cepstrum Coefficients', size=16)
i = 0
for x in range(2):
for y in range(5):
axes[x,y].set_title(list(mfcc.keys())[i])
axes[x.y].imshow(list(mfccs.values())[i],
cmap='hot', interpolation='nearest')
axes[x,y].get_xaxis().set_visible(False)
axes[x,y].get_yaxis().set_visible(False)
i+=1
df = pd.read_csv('cry.csv')
df.set_index('fname', inplace=True)
for f in df.index:
samplerate, signal = wavfile.read('Audio-Classification/wavefiles/' + f)
df.at[f, 'length'] = signal.shape[0]/samplerate
classes = list(np.unique(df.label))
class_dist = df.groupby(['label'])['length'].mean()
它显示的错误:
runfile('C:/Users/atalp/Desktop/Audio-Classification/eda.py', wdir='C:/Users/atalp/Desktop/Audio-Classification')
Traceback (most recent call last):
File "<ipython-input-20-0f3a8250d6ff>", line 1, in <module>
runfile('C:/Users/atalp/Desktop/Audio-Classification/eda.py', wdir='C:/Users/atalp/Desktop/Audio-Classification')
File "C:\Users\atalp\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\atalp\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/atalp/Desktop/Audio-Classification/eda.py", line 71, in <module>
samplerate, signal = wavfile.read('Audio-Classification/wavefiles/' + f)
File "C:\Users\atalp\Anaconda3\lib\site-packages\scipy\io\wavfile.py", line 233, in read
fid = open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'Audio-Classification/wavefiles/b1'
【问题讨论】:
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: python pandas deep-learning