# Read WAV and MP3 files to array from pydub import AudioSegment import numpy as np import pandas as pd import matplotlib.pyplot as plt #from scipy.io import wavfile #from plotly.offline import init_notebook_mode #import plotly.graph_objs as go #import plotly import sklearn import IPython from IPython.display import Image import librosa import librosa.display #import eli5 #import logguru import os import warnings warnings.filterwarnings('ignore') path=os.path.dirname(__file__) os.chdir(path) sampleFolder = os.path.join(path, 'AudioSamples') sampleList = os.listdir(sampleFolder) for sample_fileName in sampleList: print(sample_fileName) #print(sampleList[0]) filepath = os.path.join(sampleFolder,sample_fileName) #filepath = os.path.join(sampleFolder,sampleList[0]) y,sr = librosa.load(filepath,duration=2.97) ps = librosa.feature.melspectrogram(y=y, sr=sr) #print(ps.shape) #print(ps) #print(y) ##verschiedene spectral anzeigen #librosa.display.specshow(ps,y_axis='mel',x_axis='time') #librosa.display.waveplot(ps, sr=sr) X = librosa.stft(y) Xdb = librosa.amplitude_to_db(abs(X)) plt.figure(figsize=(14,5)) librosa.display.specshow(Xdb,sr=sr,x_axis='time',y_axis='hz') plt.show()