|
|
@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
|
|
|
|
import librosa
|
|
|
|
import librosa
|
|
|
|
import librosa.display
|
|
|
|
import librosa.display
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
@ -6,7 +8,7 @@ import torch
|
|
|
|
from torchlibrosa.augmentation import SpecAugmentation
|
|
|
|
from torchlibrosa.augmentation import SpecAugmentation
|
|
|
|
|
|
|
|
|
|
|
|
# 加载音频文件
|
|
|
|
# 加载音频文件
|
|
|
|
file_path = '00_BRUSH.wav'
|
|
|
|
file_path = 'test.wav'
|
|
|
|
y, sr = librosa.load(file_path, sr=None)
|
|
|
|
y, sr = librosa.load(file_path, sr=None)
|
|
|
|
|
|
|
|
|
|
|
|
# 计算音频信号的 Short-Time Fourier Transform (STFT)
|
|
|
|
# 计算音频信号的 Short-Time Fourier Transform (STFT)
|
|
|
@ -20,6 +22,7 @@ plt.figure(figsize=(10, 6))
|
|
|
|
librosa.display.specshow(spectrogram, sr=sr, x_axis='time', y_axis='log')
|
|
|
|
librosa.display.specshow(spectrogram, sr=sr, x_axis='time', y_axis='log')
|
|
|
|
plt.colorbar(format='%+2.0f dB')
|
|
|
|
plt.colorbar(format='%+2.0f dB')
|
|
|
|
plt.title('origin spectrogram')
|
|
|
|
plt.title('origin spectrogram')
|
|
|
|
|
|
|
|
|
|
|
|
plt.savefig('origin_spectrogram.png')
|
|
|
|
plt.savefig('origin_spectrogram.png')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|