Skip to content

Commit 731734f

Browse files
committed
populate recordings menu even if kinds and labels to use are blank
1 parent 5a3990c commit 731734f

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/gui/controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,12 @@ def _find_nearest_used_sound(history_idx):
743743
M.history_stack[history_idx][1]['ticks'][0])
744744
delta=0
745745
while True:
746-
if icontext_sound+delta < len(M.used_sounds) and \
746+
if 0 <= icontext_sound+delta < len(M.used_sounds) and \
747747
M.used_sounds[icontext_sound+delta]['file'] == \
748748
M.history_stack[history_idx][1]['file']:
749749
icontext_sound += delta
750750
break
751-
elif icontext_sound-delta >= 0 and \
751+
elif 0 <= icontext_sound-delta < len(M.used_sounds) and \
752752
M.used_sounds[icontext_sound-delta]['file'] == \
753753
M.history_stack[history_idx][1]['file']:
754754
icontext_sound -= delta

src/gui/view.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,12 +1194,23 @@ def cluster_these_layers_update():
11941194
cluster_these_layers.options = []
11951195

11961196
def recordings_update():
1197-
if M.dfs:
1197+
M.used_sounds = []
1198+
if kinds_touse.value=="" or labels_touse.value=="":
1199+
wavfiles = []
1200+
for ext in M.audio_read_exts():
1201+
wavfiles.extend(glob.glob("**/*"+ext,
1202+
root_dir=groundtruth_folder.value, recursive=True))
1203+
wavfiles = list(filter(lambda x: 'oldfiles-' not in x and \
1204+
'congruence-' not in x, wavfiles))
1205+
if len(M.audio_read_rec2ch()) > 1:
1206+
wavfiles = [w+'-'+k for w in wavfiles for k in M.audio_read_rec2ch().keys()]
1207+
for wavfile in wavfiles:
1208+
M.used_sounds.append({'file': list(os.path.split(wavfile)),
1209+
'ticks': [1, 1], 'kind': '', 'label': ' '})
1210+
elif M.dfs:
1211+
wavfiles = set()
11981212
kinds = kinds_touse.value.split(',')
11991213
labels = labels_touse.value.split(',')
1200-
wavfiles = set()
1201-
M.used_sounds = []
1202-
M.used_recording2firstsound = {}
12031214
for df,subdir in zip(M.dfs, M.subdirs):
12041215
bidx = np.logical_and(np.array(df[3].apply(lambda x: x in kinds)),
12051216
np.array(df[4].apply(lambda x: x in labels)))
@@ -1212,6 +1223,7 @@ def recordings_update():
12121223
1)))
12131224
wavfiles |= set(df[bidx].apply(lambda x: os.path.join(subdir,x[0]), 1))
12141225

1226+
if M.used_sounds:
12151227
M.used_starts_sorted = [x['ticks'][0] for x in M.used_sounds]
12161228
isort = np.argsort(M.used_starts_sorted)
12171229
M.used_sounds = [M.used_sounds[x] for x in isort]
@@ -1220,6 +1232,7 @@ def recordings_update():
12201232
M.iused_stops_sorted = np.argsort(M.used_stops)
12211233

12221234
recordings.options = sorted(list(wavfiles))
1235+
M.used_recording2firstsound = {}
12231236
for recording in recordings.options:
12241237
M.used_recording2firstsound[recording] = \
12251238
next(filter(lambda x: os.path.join(*x[1]['file'])==recording,

0 commit comments

Comments
 (0)