Share prepared audio names and speaker identities
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user