Revert "Revert "allow voice line alts""

This reverts commit 4fa9ee94abc31fec39f68a79ee8678d4e77f96e5.
This commit is contained in:
2022-01-02 19:11:57 -07:00
parent 6e8b9e19bf
commit 89b6c25823
3 changed files with 46 additions and 5 deletions

View File

@@ -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,

View File

@@ -22,7 +22,8 @@ enum DelayHandling {
typedef VoiceLine = {
trackKey:String,
start:Float,
end:Float
end:Float,
?alts:Array<VoiceLine>
};
enum CreditsLine {

View File

@@ -36,6 +36,7 @@
(method _currentScene [] (dictGet scenes sceneKey))
(prop &mut :Map<String,String> intercutMap)
(prop &mut :Map<String,Int> 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<VoiceLine> alts
(if line.alts
(for alt (the Array<Dynamic> line.alts) (objectWith [start alt.start end alt.end] trackKey))
[])]
(dictSet voiceLines "$actorName $key" (objectWith [start line.start end line.end] trackKey alts))))))
(defNew
[