diff --git a/scripts/cut-voice-track.py b/scripts/cut-voice-track.py index e957078..0cc07f9 100644 --- a/scripts/cut-voice-track.py +++ b/scripts/cut-voice-track.py @@ -87,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/n/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 n to repeat a search. 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. u* to use all 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: @@ -109,7 +109,26 @@ for (audio_guess, possible_sections) in timestamps.items(): save() elif choice == 'u': choice = getch() - if choice != '/' and choice in takes: + if choice == '*': + # use all the takes + print('using all') + line_with_alts = {} + choices = takes.split('/') + audio, length = audio_and_length(choices[0]) + new_data = vstack((new_data, audio)) + line_with_alts['start'] = current_sec + line_with_alts['end'] = current_sec + length + current_sec += length + alts = [] + for choice in choices[1:]: + audio, length = audio_and_length(choices[0]) + alts.append({'start': current_sec, 'end': current_sec + length}) + current_sec += length + new_data = vstack((new_data, audio)) + line_with_alts['alts'] = alts + new_json[audio_guess] = line_with_alts + break + elif choice != '/' and choice in takes: audio, length = audio_and_length(choice) new_json[audio_guess] = { 'start': current_sec, diff --git a/src/hollywoo/Movie.hx b/src/hollywoo/Movie.hx index c61ab74..b5c793a 100644 --- a/src/hollywoo/Movie.hx +++ b/src/hollywoo/Movie.hx @@ -22,7 +22,8 @@ enum DelayHandling { typedef VoiceLine = { trackKey:String, start:Float, - end:Float + end:Float, + ?alts:Array }; enum CreditsLine { diff --git a/src/hollywoo/Movie.kiss b/src/hollywoo/Movie.kiss index ce0240f..9bf77f2 100644 --- a/src/hollywoo/Movie.kiss +++ b/src/hollywoo/Movie.kiss @@ -36,6 +36,7 @@ (method _currentScene [] (dictGet scenes sceneKey)) (prop &mut :Map intercutMap) + (prop &mut :Map altIdx (new Map)) (method :Void showDialog [actorName dialogType wryly text cc] (when intercutMap (whenLet [sceneForActor (dictGet intercutMap actorName)] @@ -47,6 +48,22 @@ // Otherwise, assume it is un-voiced super text (when (and actorName (< 0 (count voiceTracks))) (case (try (dictGet voiceLines "$actorName $text") (catch [e] (print e) null)) + ((objectWith trackKey start end alts) + (case (dictGet altIdx "$actorName $text") + (null + (dictSet altIdx "$actorName $text" 0) + (director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc)) + ((when (>= idx alts.length) idx) + (dictSet altIdx "$actorName $text" 0) + (director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc)) + (idx + (let [alt (nth alts idx) + start alt.start + end alt.end] + (+= (dictGet altIdx "$actorName $text") 1) + (director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc)))) + + (set skipCC ->:Void {(director.stopVoiceTrack (dictGet voiceTracks trackKey)) (cc)})) ((objectWith trackKey start end) (director.playVoiceTrack (dictGet voiceTracks trackKey) 1 start end cc) (set skipCC ->:Void {(director.stopVoiceTrack (dictGet voiceTracks trackKey)) (cc)})) @@ -60,7 +77,11 @@ (dictSet voiceTracksPerActor actorName (+ 1 actorNumVoiceTracks)) (dictSet voiceTracks trackKey track) (doFor =>key line (lines.keyValueIterator) - (dictSet voiceLines "$actorName $key" (objectWith [start line.start end line.end] trackKey))))) + (let [:Array alts + (if line.alts + (for alt (the Array line.alts) (objectWith [start alt.start end alt.end] trackKey)) + [])] + (dictSet voiceLines "$actorName $key" (objectWith [start line.start end line.end] trackKey alts)))))) (defNew [