go-astideepspeech: github.com/asticode/go-astideepspeech Index | Files | Directories

package astideepspeech

import "github.com/asticode/go-astideepspeech"

package astideepspeech provides bindings for Mozilla's DeepSpeech speech-to-text library.

Index

Package Files

deepspeech.go

func Version Uses

func Version() string

Version returns the version of the DeepSpeech C library. The returned version is a semantic version (SemVer 2.0.0).

type CandidateTranscript Uses

type CandidateTranscript C.struct_CandidateTranscript

CandidateTranscript is a single transcript computed by the model, including a confidence value and the metadata for its constituent tokens.

func (*CandidateTranscript) Confidence Uses

func (ct *CandidateTranscript) Confidence() float64

Confidence returns the approximated confidence value for this transcript. This is roughly the sum of the acoustic model logit values for each timestep/character that contributed to the creation of this transcript.

func (*CandidateTranscript) NumTokens Uses

func (ct *CandidateTranscript) NumTokens() uint

func (*CandidateTranscript) Tokens Uses

func (ct *CandidateTranscript) Tokens() []TokenMetadata

type Metadata Uses

type Metadata C.struct_Metadata

Metadata holds an array of CandidateTranscript objects computed by the model.

func (*Metadata) Close Uses

func (m *Metadata) Close()

Close frees the Metadata structure properly.

func (*Metadata) NumTranscripts Uses

func (m *Metadata) NumTranscripts() uint

func (*Metadata) Transcripts Uses

func (m *Metadata) Transcripts() []CandidateTranscript

type Model Uses

type Model struct {
    // contains filtered or unexported fields
}

Model provides an interface to a trained DeepSpeech model.

func New Uses

func New(modelPath string) (*Model, error)

New creates a new Model. modelPath is the path to the frozen model graph.

func (*Model) BeamWidth Uses

func (m *Model) BeamWidth() uint

BeamWidth returns the beam width value used by the model. If SetModelBeamWidth was not called before, it will return the default value loaded from the model file.

func (*Model) Close Uses

func (m *Model) Close()

Close frees associated resources and destroys the model object.

func (*Model) DisableExternalScorer Uses

func (m *Model) DisableExternalScorer() error

DisableExternalScorer disables decoding using an external scorer.

func (*Model) EnableExternalScorer Uses

func (m *Model) EnableExternalScorer(scorerPath string) error

EnableExternalScorer enables decoding using an external scorer. scorerPath is the path to the external scorer file.

func (*Model) NewStream Uses

func (m *Model) NewStream() (*Stream, error)

NewStream creates a new streaming inference state. If an error is not returned, exactly one of the returned stream's Finish, FinishWithMetadata, or Discard methods must be called later to free resources.

func (*Model) SampleRate Uses

func (m *Model) SampleRate() int

SampleRate returns the sample rate that was used to produce the model file.

func (*Model) SetBeamWidth Uses

func (m *Model) SetBeamWidth(width uint) error

SetBeamWidth sets the beam width value used by the model. A larger beam width value generates better results at the cost of decoding time.

func (*Model) SetScorerAlphaBeta Uses

func (m *Model) SetScorerAlphaBeta(alpha, beta float32) error

SetScorerAlphaBeta sets hyperparameters alpha and beta of the external scorer. alpha is the language model weight. beta is the word insertion weight.

func (*Model) SpeechToText Uses

func (m *Model) SpeechToText(buffer []int16) (string, error)

SpeechToText uses the DeepSpeech model to convert speech to text. buffer is 16-bit, mono raw audio signal at the appropriate sample rate (matching what the model was trained on).

func (*Model) SpeechToTextWithMetadata Uses

func (m *Model) SpeechToTextWithMetadata(buffer []int16, numResults uint) (*Metadata, error)

SpeechToTextWithMetadata uses the DeepSpeech model to convert speech to text and output results including metadata.

buffer is a 16-bit, mono raw audio signal at the appropriate sample rate (matching what the model was trained on). numResults is the maximum number of CandidateTranscript structs to return. Returned value might be smaller than this. If an error is not returned, the returned metadata's Close method must be called later to free resources.

type Stream Uses

type Stream struct {
    // contains filtered or unexported fields
}

Stream represents a streaming inference state.

func (*Stream) Discard Uses

func (s *Stream) Discard()

Discard destroys a streaming state without decoding the computed logits. This can be used if you no longer need the result of an ongoing streaming inference and don't want to perform a costly decode operation.

func (*Stream) FeedAudioContent Uses

func (s *Stream) FeedAudioContent(buffer []int16)

FeedAudioContent feeds audio samples to an ongoing streaming inference. buffer is an array of 16-bit, mono raw audio samples at the appropriate sample rate (matching what the model was trained on).

func (*Stream) Finish Uses

func (s *Stream) Finish() (string, error)

Finish computes the final decoding of an ongoing streaming inference and returns the result. This signals the end of an ongoing streaming inference.

func (*Stream) FinishWithMetadata Uses

func (s *Stream) FinishWithMetadata(numResults uint) (*Metadata, error)

FinishWithMetadata computes the final decoding of an ongoing streaming inference and returns results including metadata. This signals the end of an ongoing streaming inference. If an error is not returned, the metadata's Close method must be called.

func (*Stream) IntermediateDecode Uses

func (s *Stream) IntermediateDecode() (string, error)

IntermediateDecode computes the intermediate decoding of an ongoing streaming inference. This is an expensive process as the decoder implementation isn't currently capable of streaming, so it always starts from the beginning of the audio.

func (*Stream) IntermediateDecodeWithMetadata Uses

func (s *Stream) IntermediateDecodeWithMetadata(numResults uint) (*Metadata, error)

IntermediateDecodeWithMetadata computes the intermediate decoding of an ongoing streaming inference, returning results including metadata. numResults is the number of candidate transcripts to return. If an error is not returned, the metadata's Close method must be called.

type TokenMetadata Uses

type TokenMetadata C.struct_TokenMetadata

TokenMetadata stores text of an individual token, along with its timing information.

func (*TokenMetadata) StartTime Uses

func (tm *TokenMetadata) StartTime() float32

StartTime returns the position of the token in seconds.

func (*TokenMetadata) Text Uses

func (tm *TokenMetadata) Text() string

Text returns the text corresponding to this token.

func (*TokenMetadata) Timestep Uses

func (tm *TokenMetadata) Timestep() uint

Timestep returns the position of the token in units of 20ms.

Directories

PathSynopsis
deepspeech

Package astideepspeech imports 3 packages (graph) and is imported by 1 packages. Updated 2020-05-28. Refresh now. Tools for package owners.