Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, audio_file, mono=True, sample_rate=44100, normalize_gain=False):
""""""
self.fs = sample_rate
if normalize_gain:
self.audio_vector = estd.EasyLoader(filename=audio_file, sampleRate=self.fs, replayGain=-9)()
else:
self.audio_vector = estd.MonoLoader(filename=audio_file, sampleRate=self.fs)()
print "== Audio vector of %s loaded with shape %s and sample rate %s ==" % (audio_file, self.audio_vector.shape, self.fs)
return
ascending_candidate, ascending_candidate_note, non_candidate_ascending_note = CS.candidate_selection(expression_style_note[:,0:3], SB.short_ascending_pattern)
# select descending candidate
descending_candidate, descending_candidate_note, non_candidate_descending_note = CS.candidate_selection(expression_style_note[:,0:3], SB.short_descending_pattern)
# save result: candidate
np.savetxt(args.output_dir+os.sep+name+'.ascending.candidate',ascending_candidate, fmt='%s')
np.savetxt(args.output_dir+os.sep+name+'.descending.candidate',descending_candidate, fmt='%s')
"""
-----------------------------------------------------
S.4.2 Extract features of selected candidate regions.
-----------------------------------------------------
"""
print ' Extracting features...'
# load audio
audio = EasyLoader(filename = f)()
# extract features of ascending candidate
feature_vec_all = extract_feature_of_audio_clip(audio, ascending_candidate, sr=contour_sr)
# write to text file
np.savetxt(args.output_dir+os.sep+name+'.ascending'+'.candidate'+'.raw.feature', feature_vec_all, fmt='%s')
# extract features of descending candidate
feature_vec_all = extract_feature_of_audio_clip(audio, descending_candidate, sr=contour_sr)
# write to text file
np.savetxt(args.output_dir+os.sep+name+'.descending'+'.candidate'+'.raw.feature', feature_vec_all, fmt='%s')
"""
-----------------------------------------------
S.4.3 Classfication using pre-train classifier.
-----------------------------------------------
"""
if len(args.input_model)==1: