我发现使用soundfile
和读取 wav 文件之间的幅度响应存在问题wavefile
。以下是不同的情节:
你能告诉我我需要调整什么wavefile.read
才能获得与 相同的幅度soundfile.read
吗?
这是我使用的代码:
import os
import matplotlib.pyplot as plt
from matplotlib import transforms
import numpy as np
import soundfile as sf
import scipy.io.wavfile as wavfile
from matplotlib.gridspec import GridSpec
input_file1 = (r'G:/file.wav')
plt.subplot(211)
a, b = sf.read(input_file1);
pxx, fs = plt.psd(a, 512, b)
plt.semilogx(fs, 10*np.log10(pxx))
plt.title('Sound File Read')
plt.grid(which='major', axis='both', color='g', linestyle='-', alpha=0.4)
plt.grid(which='minor', axis='x', color='g', linestyle='-', alpha=0.1)
plt.subplot(212)
sample_rate, signal1 = wavfile.read(input_file1)
Pxx, freq = plt.psd(signal1, 512, sample_rate)
plt.semilogx(freq, 10*np.log10(Pxx))
plt.grid(which='major', axis='both', color='g', linestyle='-', alpha=0.4)
plt.grid(which='minor', axis='x', color='g', linestyle='-', alpha=0.1)
plt.title('Wavfile File Read')
plt.ylabel('PSD')
plt.xlabel('Frequency (Hz)')
# set the spacing between subplots
plt.tight_layout()
plt.show()
谢谢!