Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alternative ¶
type Alternative struct { StartTime int64 `json:"start_time"` Duration int64 `json:"duration"` Confidence float64 `json:"confidence"` Transcript string `json:"transcript"` Words []*cubicpb.WordInfo `json:"-"` }
Alternative is a subset of the fields in cubicpb.RecognitionAlternative
func (Alternative) MarshalJSON ¶
func (a Alternative) MarshalJSON() ([]byte, error)
MarshalJSON hides the unfriendly JSON output for duration.Duration The pattern of aliasing the type we want to shadow is from the blog post http://choly.ca/post/go-json-marshalling/
type Config ¶
type Config struct {
MaxAlternatives int
}
Config holds the various options that can be used for this Formatter.
func (Config) CreateFormatter ¶
func (cfg Config) CreateFormatter() (ResultFormatter, error)
CreateFormatter returns a new Formatter instance with the given configurations
type Formatter ¶
type Formatter struct {
Cfg Config
}
Formatter can be configured to limit the number of alternatives for each result
func (Formatter) Format ¶
func (f Formatter) Format(results []*cubicpb.RecognitionResult) (string, error)
Format generates a list of formatted utterances sorted by StartTime, smallest to largest.
Some Promises: * The list will be sorted by starttime, smallest to largest. * If the startTime in milliseconds of two results are the same, they will be returned in the order the recognizer emitted them.
type Result ¶
type Result struct { ChannelID int `json:"channel_id"` Nbest []Alternative `json:"nbest"` }
Result encapsulates the Alternatives for a specific endpointed utterance
type ResultFormatter ¶
type ResultFormatter interface {
Format(results []*cubicpb.RecognitionResult) (string, error)
}
ResultFormatter formats a slice of RecognitionResults, e.g. an entire file's worth