Share prepared audio names and speaker identities
This commit is contained in:
@@ -366,7 +366,7 @@ func resolveLocalAudioFiles(sessionDir string, inputs config.SessionInputsConfig
|
||||
}
|
||||
|
||||
func materializeLocalAudioInputs(env *Env, paths artifacts.SessionPaths, resolvedAudio []string, registerInput func(kind, path, checksum string)) error {
|
||||
destinations := localAudioDestinations(resolvedAudio)
|
||||
destinations := audio.PreparedNames(resolvedAudio)
|
||||
for _, src := range resolvedAudio {
|
||||
dst := filepath.Join(paths.AudioDir, destinations[src])
|
||||
checksum, err := copyFileIfChanged(env.ArtifactStore, src, dst)
|
||||
@@ -378,43 +378,6 @@ func materializeLocalAudioInputs(env *Env, paths artifacts.SessionPaths, resolve
|
||||
return nil
|
||||
}
|
||||
|
||||
func localAudioDestinations(audioPaths []string) map[string]string {
|
||||
byBase := make(map[string][]string, len(audioPaths))
|
||||
occupied := make(map[string]bool, len(audioPaths))
|
||||
for _, audioPath := range audioPaths {
|
||||
base := filepath.Base(audioPath)
|
||||
byBase[base] = append(byBase[base], audioPath)
|
||||
occupied[base] = true
|
||||
}
|
||||
|
||||
destinations := make(map[string]string, len(audioPaths))
|
||||
ordered := append([]string(nil), audioPaths...)
|
||||
sort.Strings(ordered)
|
||||
nextSuffix := make(map[string]int)
|
||||
for _, source := range ordered {
|
||||
if _, assigned := destinations[source]; assigned {
|
||||
continue
|
||||
}
|
||||
base := filepath.Base(source)
|
||||
if len(byBase[base]) == 1 {
|
||||
destinations[source] = base
|
||||
continue
|
||||
}
|
||||
extension := filepath.Ext(base)
|
||||
stem := strings.TrimSuffix(base, extension)
|
||||
digest := sha256.Sum256([]byte(filepath.Clean(source)))
|
||||
generatedStem := stem + "-" + hex.EncodeToString(digest[:8])
|
||||
candidate := generatedStem + extension
|
||||
for occupied[candidate] {
|
||||
nextSuffix[generatedStem+extension]++
|
||||
candidate = fmt.Sprintf("%s-%d%s", generatedStem, nextSuffix[generatedStem+extension], extension)
|
||||
}
|
||||
destinations[source] = candidate
|
||||
occupied[candidate] = true
|
||||
}
|
||||
return destinations
|
||||
}
|
||||
|
||||
type s3AudioMaterializationStats struct {
|
||||
Reused int
|
||||
Downloads int
|
||||
|
||||
Reference in New Issue
Block a user