sctk

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package sctk wraps SCTK tools and provides a simpler interface for generating reports and scoring ASR hypotheses submitted in a variety of formats against reference transcripts.

Package sctk wraps SCTK tools and provides a simpler interface for generating reports and scoring ASR hypotheses submitted in a variety of formats against reference transcripts.

Package sctk wraps SCTK tools and provides a simpler interface for generating reports and scoring ASR hypotheses submitted in a variety of formats against reference transcripts.

Package sctk wraps SCTK tools and provides a simpler interface for generating reports and scoring ASR hypotheses submitted in a variety of formats against reference transcripts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunSclite

func RunSclite(
	ctx context.Context, cfg ScliteCfg, outDir, refFile string, hypFiles []Hypothesis,
) error

RunSclite executes the sclite tool on the given reference and hypothesis files, and evaluates word error rates. It also generates alignments between the reference and hypotheses, and optionally character error rate as well.

func WriteAlignment added in v0.2.0

func WriteAlignment(outPath string, aligned *AlignedHypothesis, format TableFormat) error

Types

type AlignedHypothesis added in v0.2.0

type AlignedHypothesis struct {
	SystemName string                      `json:"system_name"`
	Speakers   map[string]SpeakerSentences `json:"speakers"`
}

AlignedHypothesis contains the aligned sentences between reference and a hypothesis, indexed by speaker and sentence IDs.

func ReadAlignmentSgml added in v0.2.0

func ReadAlignmentSgml(sgmlPath string) (*AlignedHypothesis, error)

ReadAlignmentSgml reads and parses the sgml file generated by sclite, containing aligned reference and hypothesis sentences. Errors are logged, and if there are none, the data is returned as a valid *AlignedHypothesis, otherwise nil.

func (*AlignedHypothesis) ToTable added in v0.2.0

func (a *AlignedHypothesis) ToTable(f TableFormat) string

ToTable generates a report in the specified format, with the alignments for each speaker sentence presented in a table, along with other auxillary information.

type AlignedSentence added in v0.2.0

type AlignedSentence struct {
	SystemName string
	SpeakerID  string
	SentenceID string        `json:"sentence_id"`
	Sequence   int           `json:"sequence"`
	WordCount  int           `json:"word_count"`
	Words      []AlignedWord `json:"words"`
}

An AlignedSentence contains the aligned words between reference and hypothesis for a given sentence.

func (*AlignedSentence) Stats added in v0.2.0

func (s *AlignedSentence) Stats() string

Stats returns a string containing the proportion of words that the ASR system got right, substituted, deleted and inserted.

func (*AlignedSentence) ToTable added in v0.2.0

func (s *AlignedSentence) ToTable(f TableFormat) string

ToTable generates a table with three rows containing the reference and hypothesis sentence, along with the alignment label for each token.

type AlignedWord added in v0.2.0

type AlignedWord struct {
	Label string `json:"eval_label"`
	Ref   string `json:"ref"`
	Hyp   string `json:"hyp"`
}

AlignedWord contains the reference word and corresponding word in the hypothesis (if aligned). It also contains a label field which indicates the type of alignment - "correct", "substitution", "insertion", or "deletion".

type Hypothesis

type Hypothesis struct {
	SystemName string
	FilePath   string
}

A Hypothesis points to a file containing transcripts from an ASR system, along with the name of the system. The name will be used in generated reports.

type ScliteCfg added in v0.2.0

type ScliteCfg struct {
	LineWidth int
	Encoding  string
	Reports   []string
	CER       bool
}

ScliteCfg configures report generation options for sclite.

func (*ScliteCfg) Validate added in v0.2.0

func (c *ScliteCfg) Validate() error

Validate checks whether all configured options are valid and supported by sclite.

type SpeakerSentences added in v0.2.0

type SpeakerSentences map[string]*AlignedSentence

SpeakerSentences contain all the sentences of speaker indexed by sentence ID.

func (SpeakerSentences) ToTable added in v0.2.0

func (s SpeakerSentences) ToTable(f TableFormat) string

ToTable generates a table for each sentence showing the reference and hypothesis, along with the alignment label for each token. It also prints some stats about the number of errors between the reference and hypothesis.

type TableFormat added in v0.2.0

type TableFormat int

TableFormat determines in which format the alignments are written to a file.

const (
	TableFormatMarkdown TableFormat = iota
	TableFormatHTML
	TableFormatCSV
	TableFormatTxt
)

Directories

Path Synopsis
Package embedded embed SCTK tools and provides executable paths to them for other packages.
Package embedded embed SCTK tools and provides executable paths to them for other packages.
bin

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL