From f09199934f38c4d051a957ace825336e6bb613c9 Mon Sep 17 00:00:00 2001 From: George <37293288+Jorjeous@users.noreply.github.com> Date: Fri, 9 Dec 2022 00:04:00 +0400 Subject: [PATCH] Optimized loop and bugfix in SDE (#5573) - Fixed bug with loading custom data attributes from JSON in Speech Data Explorer Signed-off-by: George Zelenfroynd --- tools/speech_data_explorer/data_explorer.py | 22 +++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tools/speech_data_explorer/data_explorer.py b/tools/speech_data_explorer/data_explorer.py index 281228ad7378..3602c369b135 100755 --- a/tools/speech_data_explorer/data_explorer.py +++ b/tools/speech_data_explorer/data_explorer.py @@ -298,19 +298,15 @@ def append_data( data[-1]['I'] = measures['insertions'] data[-1]['D'] = measures['deletions'] data[-1]['D-I'] = measures['deletions'] - measures['insertions'] - else: - for k in item: - if k not in data[-1]: - data[-1][k] = item[k] - if estimate_audio: - filepath = absolute_audio_filepath(item['audio_filepath'], data_filename) - signal, sr = librosa.load(path=filepath, sr=None) - bw = eval_bandwidth(signal, sr) - item['freq_bandwidth'] = int(bw) - item['level_db'] = 20 * np.log10(np.max(np.abs(signal))) - for k in item: - if k not in data[-1]: - data[-1][k] = item[k] + if estimate_audio: + filepath = absolute_audio_filepath(item['audio_filepath'], data_filename) + signal, sr = librosa.load(path=filepath, sr=None) + bw = eval_bandwidth(signal, sr) + item['freq_bandwidth'] = int(bw) + item['level_db'] = 20 * np.log10(np.max(np.abs(signal))) + for k in item: + if k not in data[-1]: + data[-1][k] = item[k] vocabulary_data = [{'word': word, 'count': vocabulary[word]} for word in vocabulary] return (