import wave
import soundfile as sf
import numpy as np
from scipy.io import wavfile
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
wav_path =
file = wave.open(wav_path)
# print('---------声音信息------------')
a = file.getparams().nframes # 帧总数
f = file.getparams().framerate # 采样频率
sample_time = 1 / f # 采样点的时间间隔
time = a / f # 声音信号的长度
sample_frequency, audio_sequence = wavfile.read(wav_path)
# print(audio_sequence) # 声音信号每一帧的“大小”
x_seq = np.arange(0, time, sample_time)
plt.plot(x_seq, audio_sequence, 'blue')
plt.xlabel("time (s)")
plt.show()
读取wav文件,将声音信息展示出来
最新推荐文章于 2024-08-17 17:14:31 发布