python - 在 python 中读取和处理大型 wav 文件的最佳方法是什么
问题描述
这是我用来读取.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()
解决方案
推荐阅读
- amazon-iam - 谁创建用户 default_user?
- python - 图像识别模型每次都猜测同一个类
- algorithm - 稳定的婚姻问题 - 空的偏好列表
- html - Angular - 我需要为我的选项分配一个默认值
- python - Python 中的多级切片行为是否有任何规范?
- scala - com.typesafe.scala-logging#scala-logging-slf4j_2.12;2.1.2:未找到
- sql - 如何创建一对一的关系
- azure-data-explorer - 如何通过调用 Kusto 中的函数来使用分区运行子查询?
- ios - 打开 DJI Go 4 后,MSDK 中无法使用 Mavic 2 视频源
- r - 为从不同起点连续增加的 4 个数字创建 R 序列