Share prepared audio names and speaker identities

This commit is contained in:
2026-12-02 03:13:58 +00:00
parent 9b59fa16b2
commit f902e50def
9 changed files with 159 additions and 55 deletions

View File

@@ -48,8 +48,14 @@ func RequireRegularFile(name string) error {
return nil
}
// Source associates a selected local path with its prepared basename.
type Source struct {
Path string
PreparedName string
}
// DiscoverLocal selects explicit files or scans a directory without writing workspace state.
func DiscoverLocal(base string, files []string, dir string) ([]string, error) {
func DiscoverLocal(base string, files []string, dir string) ([]Source, error) {
var result []string
if len(files) != 0 {
seen := make(map[string]bool, len(files))
@@ -91,7 +97,15 @@ func DiscoverLocal(base string, files []string, dir string) ([]string, error) {
}
}
sort.Strings(result)
return result, nil
names := PreparedNames(result)
sources := make([]Source, 0, len(result))
for _, source := range result {
sources = append(sources, Source{Path: source, PreparedName: names[source]})
}
if err := ValidateSpeakerIDs(sources); err != nil {
return nil, err
}
return sources, nil
}
// ObjectLister is the read-only storage boundary required for audio selection.
@@ -124,5 +138,12 @@ func DiscoverS3(ctx context.Context, store ObjectLister, prefix string) ([]stora
if len(result) == 0 {
return nil, fmt.Errorf("no audio candidates found under s3 audio prefix %q", prefix)
}
sources := make([]Source, 0, len(result))
for _, obj := range result {
sources = append(sources, Source{Path: obj.Key, PreparedName: path.Base(obj.Key)})
}
if err := ValidateSpeakerIDs(sources); err != nil {
return nil, err
}
return result, nil
}