import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns import librosa import librosa.display # Definice color palety color_pal = plt.rcParams["axes.prop_cycle"].by_key()["color"] def process_signal_from_csv(csv_file_path): # Load signal from CSV df = pd.read_csv(csv_file_path) y = df.iloc[:, 0].values sr = 22050 # Display raw signal pd.Series(y).plot(figsize=(10, 5), lw=1, title='Raw Signal Example', color=color_pal[0]) plt.show() # Spectrogram D = librosa.stft(y, n_fft=1024, hop_length=2, win_length=128) S_db = librosa.amplitude_to_db(np.abs(D), ref=np.max) # Plot spectrogram fig, ax = plt.subplots(figsize=(10, 5)) img = librosa.display.specshow(S_db, y_axis='hz', fmin=0, fmax=17000, ax=ax) ax.set_title('Spectrogram', fontsize=20) fig.colorbar(img, ax=ax, format='%0.002f') plt.show() # Save spectrogram fig.savefig('Spectogram.png') return y, sr, S_db # Pouziti csv_file_path = #nacist CSV file y, sr, spectrogram = process_signal_from_csv(csv_file_path)