model

package
v0.0.0-...-0e3e81a Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BeamWidth = 500
	LMAlpha   = 0.931289039105002
	LMBeta    = 1.1834137581510284
)

Variables

View Source
var (
	// Missing model
	ErrNoModel = errNoModel(0x1000)

	// Invalid parameters
	ErrInvalidAlphabet       = errInvalidAlphabet(0x2000)
	ErrInvalidShape          = errInvalidShape(0x2001)
	ErrInvalidScorer         = errInvalidScorer(0x2002)
	ErrModelIncompatible     = errModelIncompatible(0x2003)
	ErrScorerNotEnabled      = errScorerNotEnabled(0x2004)
	ErrScorerUnreadable      = errScorerUnreadable(0x2005)
	ErrScorerInvalidLM       = errScorerInvalidLM(0x2006)
	ErrScorerNoTrie          = errScorerNoTrie(0x2007)
	ErrScorerInvalidTrie     = errScorerInvalidTrie(0x2008)
	ErrScorerVersionMismatch = errScorerVersionMismatch(0x2009)

	// Runtime failures
	ErrFailInitMMAP     = errFailInitMMAP(0x3000)
	ErrFailInitSess     = errFailInitSess(0x3001)
	ErrFailInterpreter  = errFailInterpreter(0x3002)
	ErrFailRunSess      = errFailRunSess(0x3003)
	ErrFailCreateStream = errFailCreateStream(0x3004)
	ErrFailReadProtobuf = errFailReadProtobuf(0x3005)
	ErrFailCreateSess   = errFailCreateSess(0x3006)
	ErrFailCreateModel  = errFailCreateModel(0x3007)

	ErrOpenStreams = errors.New("open streams")
)

Functions

func ErrorOf

func ErrorOf(code int) error

func SetVersion

func SetVersion(v string)

func Version

func Version() string

Types

type CandidateTranscript

type CandidateTranscript struct {
	Tokens     []TokenMetadata
	Confidence float64
}

type Error

type Error int

func (Error) Error

func (e Error) Error() string

type Hypothesis

type Hypothesis struct {
	Candidates []HypothesisCandidate
}

type HypothesisCandidate

type HypothesisCandidate struct {
	Text       string
	Confidence float64
	StartStep  int
	EndStep    int
	StartTime  time.Duration
	EndTime    time.Duration
	Duration   time.Duration
	Words      []Word
}

type Metadata

type Metadata struct {
	Transcripts []CandidateTranscript
}

type Model

type Model interface {
	EnableExternalScorer(path string, aAlpha, aBeta float32) error

	SampleRate() int

	Close() error

	SpeechToText(frame []int16) string

	CreateStream() (Stream, error)
}

type Stream

type Stream interface {
	Free() error

	IntermediateDecode() string

	FeedAudioContent(frame []int16)

	IntermediateDecodeWithMetadata(aNumResults uint32) *Metadata

	FinishStream() string

	FinishStreamWithMetadata(aNumResults uint32) *Metadata

	FinishStreamWithBestHypothesis(aNumResults uint32) *HypothesisCandidate

	FinishStreamWithHypothesis(aNumResults uint32) Hypothesis
}

type TokenMetadata

type TokenMetadata struct {
	Text      string
	Timestep  int
	StartTime float32
}

type Word

type Word struct {
	Whitespace bool
	Value      string
	StartStep  int
	EndStep    int
	StartTime  time.Duration
	EndTime    time.Duration
	Duration   time.Duration
}

Jump to

Keyboard shortcuts

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