Spaces:
Running
on
Zero
Running
on
Zero
File size: 892 Bytes
c3c908f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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+)")
|