这是我用来读取.wav
文件以计算信号包络的代码。它确实可以正常工作,但是当我尝试读取大于200MB的文件时,它将无法正常工作。
任何帮助都是真的。
import matplotlib.pyplot as plt
import numpy as np
from scipy.io.wavfile import read
from tkinter import filedialog
# Browse, read the signal and extract signal informations (fs, duration)
filename = filedialog.askopenfilename(filetypes = (("""
Template files""", "*.wav"), ("All files", "*")))
fs, data = read(filename, mmap=True)
T = len(data) / fs #duration
nsamples = T * fs #number of samples
time = np.linspace(0, T, nsamples)
# Compute the envelope of the signal
from scipy.signal import hilbert
analytic_signal = hilbert(data)
len_E = len(amplitude_envelope)
t2 = np.linspace(0,T,len_E)
# Plot the signal and its envelope
plt.figure()
plt.subplot(211)
plt.plot(time, data)
plt.subplot(212)
plt.plot(t2,amplitude_envelope)
plt.show()