<commit_before>import sys
sys.path.append('python_speech_features')
from features import logfbank
from features import mfcc
import scipy.io.wavfile as wav
import matplotlib.pyplot as plt
import numpy as np

#snip the edges of the utterance to fit the sliding window
#	sig: audio signal
#	rate: sampling rate
#	winlen: length of the sliding window [s]
#	winstep: stepsize of the sliding window [s]
def snip(sig, rate, winlen, winstep):
	# calculate the number of frames in the utterance as number of samples in the utterance / number of samples in the frame
	num_frames = int((len(sig)-winlen*rate)/(winstep*rate)) 
	# cut of the edges to fit the number of frames
	sig = sig[0:int(num_frames*winstep*rate + winlen*rate)]
	
	return sig

#Compute fbank features
#	sig: audio signal
#	rate: sampling rate
#	winlen: length of the sliding window [s]
#	winstep: stepsize of the sliding window [s]
#	nfilt: number of mel filters
#	nfft: number of fft bins
#	lowfreq: low cuttof frequency
# highfreq: high cuttoff
# preemph: pre-emphesis coefficient
# include_energy: if set to True the energy will be appended to the features
# snip_edges: if set to true the signal will be cut so the length is appropriate for the sliding window length and step, otherwise the window will go over the edge and pad the signal
def compute_fbank(sig, rate, winlen=0.025,winstep=0.01, nfilt=39, nfft=512, lowfreq=0, highfreq=None, preemph=0.97, include_energy=True, snip_edges = True):<commit_msg>starting further cleanup of code<commit_after>import sys
sys.path.append('python_speech_features')
from features import logfbank
from features import mfcc
import scipy.io.wavfile as wav
import numpy as np

#snip the edges of the utterance to fit the sliding window
#	sig: audio signal
#	rate: sampling rate
#	winlen: length of the sliding window [s]
#	winstep: stepsize of the sliding window [s]
def snip(sig, rate, winlen, winstep):
	# calculate the number of frames in the utterance as number of samples in the utterance / number of samples in the frame
	num_frames = int((len(sig)-winlen*rate)/(winstep*rate)) 
	# cut of the edges to fit the number of frames
	sig = sig[0:int(num_frames*winstep*rate + winlen*rate)]
	
	return sig

#Compute fbank features
#	sig: audio signal
#	rate: sampling rate
#	winlen: length of the sliding window [s]
#	winstep: stepsize of the sliding window [s]
#	nfilt: number of mel filters
#	nfft: number of fft bins
#	lowfreq: low cuttof frequency
# highfreq: high cuttoff
# preemph: pre-emphesis coefficient
# include_energy: if set to True the energy will be appended to the features
# snip_edges: if set to true the signal will be cut so the length is appropriate for the sliding window length and step, otherwise the window will go over the edge and pad the signal
def compute_fbank(sig, rate, winlen=0.025,winstep=0.01, nfilt=39, nfft=512, lowfreq=0, highfreq=None, preemph=0.97, include_energy=True, snip_edges = True):
{'fraction_non_alphanumeric': 0.07555555555555556, 'fraction_numerical': 0.011623931623931624, 'mean_word_length': 5.045454545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4770134', 'n_tokens_mistral': 952, 'n_tokens_neox': 913, 'n_words': 397}