Spaces:
Running
on
Zero
Running
on
Zero
| import librosa | |
| import librosa.display | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| # πΉ μ€λμ€ νμΌ λ‘λ | |
| file_real = "/path/to/real_audio.wav" # Real μ€λμ€ κ²½λ‘ | |
| file_fake = "/path/to/generative_audio.wav" # AI μμ± μ€λμ€ κ²½λ‘ | |
| def plot_spectrogram(audio_file, title): | |
| y, sr = librosa.load(audio_file, sr=16000) # μνλ§ λ μ΄νΈ 16kHz | |
| D = librosa.amplitude_to_db(np.abs(librosa.stft(y)), ref=np.max) # STFT λ³ν | |
| plt.figure(figsize=(10, 4)) | |
| librosa.display.specshow(D, sr=sr, x_axis='time', y_axis='hz', cmap='magma') | |
| plt.colorbar(format='%+2.0f dB') | |
| plt.title(title) | |
| plt.ylim(4000, 16000) # 4kHz μ΄μ κ³ μ£Όν μμλ§ νμ | |
| plt.show() | |
| # πΉ Real vs Generative Spectrogram λΉκ΅ | |
| plot_spectrogram(file_real, "Real Audio Spectrogram (4kHz+)") | |
| plot_spectrogram(file_fake, "Generative Audio Spectrogram (4kHz+)") | |