import math
import wave
import numpy as np
import pylab as pl
def ZeroCR(waveData,frameSize,overLap):
wlen = len(waveData)
step = frameSize - overLap
frameNum = math.ceil(wlen/step)
zcr = np.zeros((frameNum,1))
for i in range(frameNum):
curFrame = waveData[np.arange(i*step,min(i*step+frameSize,wlen))]
#To avoid DC bias, usually we need to perform mean subtraction on each frame
curFrame = curFrame - np.mean(curFrame) # zero-justified
zcr[i] = sum(curFrame[0:-1]*curFrame[1::]<=0)
# print(zcr[i])
return zcr
fw = wave.open(r'D:\Workspace\dejavu\preprocessing\tool\aim call wav file\guanji 4.wav','rb')
params = fw.getparams()
print(params)
nchannels, sampwidth, framerate, nframes = params[:4]
str_data = fw.readframes(nframes)
wave_data = np.fromstring(str_data, dtype=np.int16)
Wave_data = wave_data*1.0/(max(abs(wave_data)))#wave amplitude normalization
fw.close()
# calculate Zero Cross Rate
frameSize = 512
overLap = 0
zcr = ZeroCR(wave_data,frameSize,overLap)
zcr_1=zcr.T
print(zcr_1)
time = np.arange(0, len(wave_data)) * (1.0 / framerate)
time2 = np.arange(0, len(zcr)) * (len(wave_data)/len(zcr) / framerate)
pl.subplot(211)
pl.plot(time, wave_data)
pl.ylabel("Amplitude")
pl.subplot(212)
pl.plot(time2, zcr)
pl.ylabel("ZCR")
pl.xlabel("time (seconds)")
pl.show()
The idea of using double threshold method: First, the spectral entropy of the noise segment (high randomness and high confusion) is greater than the speech segment, distinguishing the voiced and noi...
1. Introduction to the concept The short-term zero-crossing rate can be regarded as a simple measure of the signal frequency and is a rough estimate of the spectral characteristics. (1) Zero crossing ...
1. Principle: The short-term average zero-crossing rate indicates the number of times the speech signal waveform crosses the horizontal axis in a frame of speech Two, calculate the zero-crossing rate ...
The first way: Beep The second way: Music (wav format or mp3 format) Installation playsound library pip install playsound Run the sample:...
Description This article mainly uses python programming to parse the wav voice file, and get the number of channels, quantization bits, sampling frequency, and number of sampling points of the .wav vo...
Features: (1) Read the local .mat file (2) Convert the .mat file to .WAV file output (3) Play .WAV file instruction: When you need to run, you only need the following programs Where the LoadMAT path r...
Foreword Because the sound source data is required to be stored in the C file from the WAV, try to use Python parsing. Reference article Data in WAV files need to pay attention to large end and small ...
Copyright Notice: All articles in this blog use the CC BY-NC-SA 4.0 license agreement unless otherwise stated. Please indicate the source! Https://blog.csdn.net/huplion/article/details/81040734 1)scip...
Convert all pcm files under pcm_path to wav files...