From 1594c8de4ecc8dec9b31b84f355e2e19ec50981b Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 17 Dec 2021 15:37:07 -0700 Subject: [PATCH] allow repeating a search in cut-voice-track --- projects/hollywoo/scripts/cut-voice-track.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/hollywoo/scripts/cut-voice-track.py b/projects/hollywoo/scripts/cut-voice-track.py index 4f5b3355..e957078a 100644 --- a/projects/hollywoo/scripts/cut-voice-track.py +++ b/projects/hollywoo/scripts/cut-voice-track.py @@ -51,6 +51,7 @@ def save(): current_sec = 0 searching_for = None +last_search = None for (audio_guess, possible_sections) in timestamps.items(): if searching_for != None: if searching_for in audio_guess: @@ -86,11 +87,11 @@ for (audio_guess, possible_sections) in timestamps.items(): return data[start_frame:end_frame], end - start print('\033[31m' + audio_guess + '\033[0m') - print(f'{takes}/u({takes})/d/f/h/q') + print(f'{takes}/u({takes})/d/f/n/h/q') while True: choice = getch() if choice == 'h': - print(f'{num_takes} takes. Type {takes} to play one. Type u + {takes} to use one of them. Type f to search ahead for a word or phrase. Type d to discard this snippet. Type q to quit') + print(f'{num_takes} takes. Type {takes} to play one. Type u + {takes} to use one of them. Type f to search ahead for a word or phrase. Type n to repeat a search. Type d to discard this snippet. Type q to quit') elif choice == 'd': break elif choice != '/' and choice in takes: @@ -98,8 +99,12 @@ for (audio_guess, possible_sections) in timestamps.items(): play_buffer(audio, nchannels, sampwidth, framerate) elif choice == 'f': phrase = input("phrase (lower-case) to search for?") + last_search = phrase searching_for = phrase break + elif choice == 'n': + searching_for = last_search + break elif choice == 'q': save() elif choice == 'u':