[O] Reformat
This commit is contained in:
+8
-22
@@ -7,6 +7,7 @@ import os
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
from inaSpeechSegmenter.features import to_wav
|
from inaSpeechSegmenter.features import to_wav
|
||||||
|
from numba import float32
|
||||||
from scipy.fftpack.realtransforms import dct
|
from scipy.fftpack.realtransforms import dct
|
||||||
from scipy.signal import lfilter, hamming
|
from scipy.signal import lfilter, hamming
|
||||||
from scipy.fftpack import fft, ifft
|
from scipy.fftpack import fft, ifft
|
||||||
@@ -238,8 +239,10 @@ def specPS(input_wav,pitch):
|
|||||||
for k, l in zip(specs[0], specs[1]):
|
for k, l in zip(specs[0], specs[1]):
|
||||||
m = math.sqrt((k ** 2) + (l ** 2))
|
m = math.sqrt((k ** 2) + (l ** 2))
|
||||||
if m > 0: m = math.log(m)
|
if m > 0: m = math.log(m)
|
||||||
if m == 0: m = epsilon
|
if m == 0:
|
||||||
elif m < 0: m = np.nan
|
m = epsilon
|
||||||
|
elif m < 0:
|
||||||
|
m = np.nan
|
||||||
peri.append(m)
|
peri.append(m)
|
||||||
# Filter the spectrum through the triangle filterbank
|
# Filter the spectrum through the triangle filterbank
|
||||||
mspec = np.log10(peri)
|
mspec = np.log10(peri)
|
||||||
@@ -248,12 +251,12 @@ def specPS(input_wav,pitch):
|
|||||||
return ceps[:50]
|
return ceps[:50]
|
||||||
|
|
||||||
|
|
||||||
def build_single_feature_row(data, Atal):
|
def build_single_feature_row(data: float32[:], Atal):
|
||||||
lpcs = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
|
lpc_orders = np.array([8, 9, 10, 11, 12, 13, 14, 15, 16, 17])
|
||||||
arr = []
|
arr = []
|
||||||
periodo = specPS(data, 50)
|
periodo = specPS(data, 50)
|
||||||
arr.extend(periodo)
|
arr.extend(periodo)
|
||||||
for j in lpcs:
|
for j in lpc_orders:
|
||||||
if Atal:
|
if Atal:
|
||||||
ars = arspecs(data, j, Atal=True)
|
ars = arspecs(data, j, Atal=True)
|
||||||
else:
|
else:
|
||||||
@@ -284,20 +287,3 @@ def create_features(input_wav_filename, feature_filename, begin=None, end=None,
|
|||||||
os.remove(wav)
|
os.remove(wav)
|
||||||
|
|
||||||
return arcep_mat
|
return arcep_mat
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
# parse arguments
|
|
||||||
parser = argparse.ArgumentParser(description='Extract features for formants estimation.')
|
|
||||||
parser.add_argument('wav_file', default='', help="WAV audio filename (single vowel or an whole utternace)")
|
|
||||||
parser.add_argument('feature_file', default='', help="output feature text file")
|
|
||||||
parser.add_argument('--begin', help="beginning time in the WAV file", default=0.0, type=float)
|
|
||||||
parser.add_argument('--end', help="end time in the WAV file", default=-1.0, type=float)
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
if args.begin > 0.0 or args.end > 0.0:
|
|
||||||
create_features(args.wav_file, args.feature_file, args.begin, args.end)
|
|
||||||
else:
|
|
||||||
create_features(args.wav_file, args.feature_file)
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user