Mid indexing problem fix
This commit is contained in:
@@ -75,7 +75,7 @@ class Analysis(object):
|
||||
# be saved in the HDF5 file
|
||||
data_dict, attrs_dict = self.hdf5_dataset_formatter(*args, **kwargs)
|
||||
for key, value in data_dict.iteritems():
|
||||
self.analysis.create_dataset(key, data=value)
|
||||
self.analysis.create_dataset(key, data=value, dtype=np.float, chunks=True)
|
||||
for key, value in attrs_dict.iteritems():
|
||||
self.analysis.attrs[key] = value
|
||||
|
||||
@@ -145,6 +145,9 @@ class Analysis(object):
|
||||
}
|
||||
output = np.empty(len(selection))
|
||||
|
||||
if not selection.size:
|
||||
# TODO: Add warning here
|
||||
return np.nan
|
||||
# For debugging apply_along_axis:
|
||||
#for ind, i in enumerate(selection):
|
||||
# output[ind] = self.formatter_func(i, frames, valid_inds, formatter=format_style_dict[format])
|
||||
|
||||
@@ -251,17 +251,24 @@ class F0Analysis(Analysis):
|
||||
}
|
||||
|
||||
# For debugging apply along axis:
|
||||
if not selection.size:
|
||||
# TODO: Add warning here
|
||||
return np.nan
|
||||
|
||||
#for ind, i in enumerate(selection):
|
||||
# output[ind] = self.formatter_func(i, frames, valid_inds, harm_ratio, formatter=format_style_dict[format])
|
||||
|
||||
output = np.apply_along_axis(
|
||||
self.formatter_func,
|
||||
1,
|
||||
selection,
|
||||
frames,
|
||||
valid_inds,
|
||||
formatter=format_style_dict[format]
|
||||
)/self.nyquist_rate
|
||||
try:
|
||||
output = np.apply_along_axis(
|
||||
self.formatter_func,
|
||||
1,
|
||||
selection,
|
||||
frames,
|
||||
valid_inds,
|
||||
formatter=format_style_dict[format]
|
||||
)/self.nyquist_rate
|
||||
except IndexError:
|
||||
pdb.set_trace()
|
||||
|
||||
return output
|
||||
|
||||
|
||||
@@ -82,6 +82,10 @@ class F0HarmRatioAnalysis(Analysis):
|
||||
#for ind, i in enumerate(selection):
|
||||
# output[ind] = self.formatter_func(i, frames, valid_inds, harm_ratio, formatter=format_style_dict[format])
|
||||
|
||||
if not selection.size:
|
||||
# TODO: Add warning here
|
||||
return np.nan
|
||||
|
||||
output = np.apply_along_axis(
|
||||
self.formatter_func,
|
||||
1,
|
||||
|
||||
@@ -264,7 +264,6 @@ def main():
|
||||
log_filename=modpath,
|
||||
logger_filelevel=args.verbose
|
||||
)
|
||||
pdb.set_trace()
|
||||
|
||||
# Create/load a pre-existing source database
|
||||
source_db = AudioDatabase(
|
||||
|
||||
@@ -410,24 +410,33 @@ class Matcher:
|
||||
target_data, s = target_entry.analysis_data_grains(target_times, analysis, format=analysis_formatting)
|
||||
all_target_analyses[i] = target_data
|
||||
|
||||
|
||||
imp = Imputer(axis=1)
|
||||
nan_columns = np.all(np.isnan(all_target_analyses), axis=1)
|
||||
all_target_analyses[nan_columns, :] = 0.
|
||||
# Impute values for Nans
|
||||
all_target_analyses = imp.fit_transform(all_target_analyses)
|
||||
|
||||
for sind, source_entry in enumerate(self.source_db.analysed_audio):
|
||||
self.logger.info("K-d Tree Matching: {0} to {1}".format(source_entry.name, target_entry.name))
|
||||
# Create an array of grain times for source sample
|
||||
source_times = source_entry.generate_grain_times(grain_size, overlap, save_times=True)
|
||||
if not source_times.size:
|
||||
continue
|
||||
|
||||
all_source_analyses = np.empty((len(self.matcher_analyses), source_times.shape[0]))
|
||||
|
||||
|
||||
for i, analysis in enumerate(self.matcher_analyses):
|
||||
analysis_formatting = self.analysis_dict[analysis]
|
||||
|
||||
source_data, s = source_entry.analysis_data_grains(source_times, analysis, format=analysis_formatting)
|
||||
all_source_analyses[i] = source_data
|
||||
|
||||
self.logger.info("K-d Tree Matching: {0} to {1}".format(source_entry.name, target_entry.name))
|
||||
|
||||
# Impute values for Nans
|
||||
nan_columns = np.all(np.isnan(all_source_analyses), axis=1)
|
||||
all_source_analyses[nan_columns, :] = 0.
|
||||
all_source_analyses = imp.fit_transform(all_source_analyses)
|
||||
|
||||
source_tree = spatial.cKDTree(all_source_analyses.T, leafsize=100)
|
||||
@@ -448,6 +457,7 @@ class Matcher:
|
||||
match_vals = best_match_vals[:, :self.match_quantity]
|
||||
|
||||
match_grain_inds = self.calculate_db_inds(match_indexes, source_sample_indexes)
|
||||
pdb.set_trace()
|
||||
|
||||
datafile_path = ''.join(("match/", target_entry.name))
|
||||
try:
|
||||
@@ -787,6 +797,7 @@ class Synthesizer:
|
||||
# from available matches.
|
||||
match_index = np.random.randint(matches.shape[0])
|
||||
match_db_ind, match_grain_ind = matches[match_index]
|
||||
pdb.set_trace()
|
||||
with self.match_db.analysed_audio[match_db_ind] as match_sample:
|
||||
match_sample.generate_grain_times(match_grain_size, match_overlap, save_times=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user