Added support for a minimal JSON output schema
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
const (
|
||||
DefaultInputReader = "json-files"
|
||||
DefaultOutputModules = "json"
|
||||
DefaultOutputSchema = OutputSchemaSeriatim
|
||||
DefaultPreprocessingModules = "validate-raw,normalize-speakers,trim-text"
|
||||
DefaultPostprocessingModules = "detect-overlaps,resolve-overlaps,backchannel,filler,coalesce,detect-overlaps,autocorrect,assign-ids,validate-output"
|
||||
DefaultOverlapWordRunGap = 0.75
|
||||
@@ -25,6 +26,8 @@ const (
|
||||
WordRunReorderWindowEnv = "SERIATIM_OVERLAP_WORD_RUN_REORDER_WINDOW"
|
||||
BackchannelMaxDurationEnv = "SERIATIM_BACKCHANNEL_MAX_DURATION"
|
||||
FillerMaxDurationEnv = "SERIATIM_FILLER_MAX_DURATION"
|
||||
OutputSchemaSeriatim = "seriatim"
|
||||
OutputSchemaMinimal = "minimal"
|
||||
)
|
||||
|
||||
// MergeOptions captures raw CLI option values before validation.
|
||||
@@ -36,6 +39,7 @@ type MergeOptions struct {
|
||||
AutocorrectFile string
|
||||
InputReader string
|
||||
OutputModules string
|
||||
OutputSchema string
|
||||
PreprocessingModules string
|
||||
PostprocessingModules string
|
||||
CoalesceGap string
|
||||
@@ -50,6 +54,7 @@ type Config struct {
|
||||
AutocorrectFile string
|
||||
InputReader string
|
||||
OutputModules []string
|
||||
OutputSchema string
|
||||
PreprocessingModules []string
|
||||
PostprocessingModules []string
|
||||
OverlapWordRunGap float64
|
||||
@@ -64,6 +69,7 @@ func NewMergeConfig(opts MergeOptions) (Config, error) {
|
||||
cfg := Config{
|
||||
InputReader: strings.TrimSpace(opts.InputReader),
|
||||
OutputModules: nil,
|
||||
OutputSchema: strings.TrimSpace(opts.OutputSchema),
|
||||
PreprocessingModules: nil,
|
||||
PostprocessingModules: nil,
|
||||
OverlapWordRunGap: DefaultOverlapWordRunGap,
|
||||
@@ -76,6 +82,12 @@ func NewMergeConfig(opts MergeOptions) (Config, error) {
|
||||
if cfg.InputReader == "" {
|
||||
return Config{}, errors.New("--input-reader is required")
|
||||
}
|
||||
if cfg.OutputSchema == "" {
|
||||
cfg.OutputSchema = DefaultOutputSchema
|
||||
}
|
||||
if err := validateOutputSchema(cfg.OutputSchema); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
var err error
|
||||
cfg.OutputModules, err = parseModuleList(opts.OutputModules)
|
||||
@@ -174,6 +186,15 @@ func parseModuleList(value string) ([]string, error) {
|
||||
return names, nil
|
||||
}
|
||||
|
||||
func validateOutputSchema(value string) error {
|
||||
switch value {
|
||||
case OutputSchemaSeriatim, OutputSchemaMinimal:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("--output-schema must be one of %q or %q", OutputSchemaSeriatim, OutputSchemaMinimal)
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeInputFiles(paths []string) ([]string, error) {
|
||||
if len(paths) == 0 {
|
||||
return nil, errors.New("at least one --input-file is required")
|
||||
|
||||
Reference in New Issue
Block a user