def enframe(signal, frame_len=frame_len, frame_shift=frame_shift, win=np.hamming(frame_len)):
"""Enframe with Hamming widow function.
:param signal: The signal be enframed
:param win: window function, default Hamming
:returns: the enframed signal, num_frames by frame_len array
"""
num_samples = signal.size
// num_frames表示总共有多少个帧
// 帧长frame_len表示一帧包含多少个点
// 帧移frame_shift表示一个帧移中包含多少个点
num_frames = np.floor((num_samples - frame_len) / frame_shift) + 1
frames = np.zeros((int(num_frames), frame_len))
for i in range(int(num_frames)): # 将分帧后的每帧信号拼接成一个矩阵
frames[i, :] = signal[i * frame_shift:i * frame_shift + frame_len]
frames[i, :] = frames[i, :] * win
return frames