cut-voice-tracks.py allow rewriting transcriptions
This commit is contained in:
@@ -55,7 +55,7 @@ def process_chunk(audio_guess, possible_sections):
|
||||
return start, end
|
||||
|
||||
print('\033[31m' + audio_guess + '\033[0m')
|
||||
print(f'{takes}/u({takes}/*)/d/f/n/h/q')
|
||||
print(f'{takes}/u({takes}/*)/d/f/n/r/h/q')
|
||||
while True:
|
||||
choice = getch()
|
||||
if choice == 'h':
|
||||
@@ -64,6 +64,7 @@ def process_chunk(audio_guess, possible_sections):
|
||||
print(f'u + {takes} - use a take.')
|
||||
print(f'u + * - use all takes as alts.')
|
||||
print('f - search ahead for a word or phrase')
|
||||
print('r - rewrite the transcription of this snippet for better matching')
|
||||
print('n - repeat a search.')
|
||||
print('d - discard this snippet.')
|
||||
print('q - save and quit')
|
||||
@@ -75,6 +76,9 @@ def process_chunk(audio_guess, possible_sections):
|
||||
elif choice == 'f':
|
||||
cutter.search()
|
||||
break
|
||||
elif choice == 'r':
|
||||
cutter.rewrite_transcription(audio_guess, process_chunk)
|
||||
break
|
||||
elif choice == 'n':
|
||||
cutter.repeat_search()
|
||||
break
|
||||
|
@@ -23,6 +23,8 @@ def args(starting_num, usage, default=None):
|
||||
|
||||
class AudioCutter:
|
||||
def __init__(self, wav_file, json_file):
|
||||
self.json_file = json_file
|
||||
|
||||
# Store a wav file's sound data and json data representing tagged chunks of audio in the wav
|
||||
with open(json_file, 'r') as f:
|
||||
self.json_info = json.load(f)
|
||||
@@ -80,6 +82,17 @@ class AudioCutter:
|
||||
def repeat_search(self):
|
||||
self.searching_for = self.last_search
|
||||
|
||||
def rewrite_transcription(self, audio_tag, chunk_processor=None):
|
||||
info = self.json_info[audio_tag]
|
||||
new_audio_tag = input("new transcription? ")
|
||||
|
||||
self.json_info[new_audio_tag] = info
|
||||
self.json_info.pop(audio_tag, None)
|
||||
with open(self.json_file, 'w') as f:
|
||||
json.dump(self.json_info, f)
|
||||
if chunk_processor is not None:
|
||||
chunk_processor(new_audio_tag, info)
|
||||
|
||||
def process_audio(self, chunk_processor, new_wav_file):
|
||||
for (audio_tag, chunk_info) in self.json_info.items():
|
||||
# When the AudioCutter is searching for a phrase, skip all audio tags that don't match
|
||||
|
Reference in New Issue
Block a user