我试图找出哪个是 wav 文件的最高值。首先我读取 wav,然后找到最大值的样本,但现在我需要知道那个值是哪个值。我无法上传 wav 文件,但您可以与任何人一起尝试。
import matplotlib.pyplot as plt
import numpy as np
import wave
import sys
spf1 = wave.open('C:/Users/Martinez/Documents/Diego/Facultad/Proyecto Final/Mediciones Cubo/5 sentado/Lado 1_5 sentado.wav','r')
#Extract Raw Audio from Wav File
signal1 = spf1.readframes(-1)
signal1 = np.fromstring(signal1, 'Int16')
fs1 = spf1.getframerate()
#If Stereo
if spf1.getnchannels() == 2:
print 'Just mono files'
sys.exit(0)
#print np.arange(signal)
m_x = abs(signal1).argmax()
m_y = abs(signal1).max()
print m_x
print m_y
Time=np.linspace(0, len(signal1)/float(fs1), num=len(signal1))
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.vlines(Time[m:], [0], abs(signal1)[m:] )
#ax1.plot(Time[m:], abs(signal1[m:]), 'r')
ax1.grid(True)
ax1.axhline(color='black', lw=2)
plt.show()