pocketsphinx

package module
v0.0.0-...-e8247d3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: BSD-2-Clause Imports: 9 Imported by: 3

README

go-pocketsphinx

Pocketsphinx binding for Golang

preparation

  • Build and install sphinxbase and pocketsphinx at /usr/local

installation

go get github.com/shunsukeaihara/go-pocketsphinx

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Hmm           string
	Dict          string
	Lm            string
	Jsgf          string
	Bestpath      string
	Beam          NullFloat
	Wbeam         NullFloat
	Keyphrase     string
	Kws           string
	Kws_threshold NullFloat
	Kws_plp       NullFloat
	Debug         NullInt
	SamplingRate  NullFloat
	DisableInfo   bool
	Language      string
}

func Load

func Load(r io.Reader) (Config, error)

func (Config) Mode

func (c Config) Mode() string

func (Config) SetParams

func (c Config) SetParams(psConfig *C.cmd_ln_t)

type NullFloat

type NullFloat null.Float

func FloatParam

func FloatParam(f float64) NullFloat

func (*NullFloat) UnmarshalText

func (f *NullFloat) UnmarshalText(text []byte) error

type NullInt

type NullInt null.Int

func IntParam

func IntParam(i int64) NullInt

func (*NullInt) UnmarshalText

func (f *NullInt) UnmarshalText(text []byte) error

type PocketSphinx

type PocketSphinx struct {
	Config Config
	// contains filtered or unexported fields
}

PocketSphinx is a speech recognition decoder object

func NewPocketSphinx

func NewPocketSphinx(config Config) *PocketSphinx

NewPocketSphinx creates PocketSphinx instance with Config.

func (*PocketSphinx) EndUtt

func (p *PocketSphinx) EndUtt() error

EndUtt ends utterance processing.

func (*PocketSphinx) Free

func (p *PocketSphinx) Free()

Free releases all resources associated with the PocketSphinx.

func (*PocketSphinx) GetHyp

func (p *PocketSphinx) GetHyp(segment bool) (Result, error)

GetHyp gets speech recognition result for best hypothesis. If segment is true, result contains word segments in recognized text.

func (*PocketSphinx) GetInSpeech

func (p *PocketSphinx) GetInSpeech() bool

func (*PocketSphinx) GetNbest

func (p *PocketSphinx) GetNbest(numNbest int, segment bool) []Result

func (*PocketSphinx) ProcessRaw

func (p *PocketSphinx) ProcessRaw(raw []byte, noSearch, fullUtt bool) error

ProcessRaw processes a single channel, 16-bit pcm signal. if noSearch is true, ProcessRaw performs only feature extraction but don't do any recognition yet. if fullUtt is true, this block of data is a full utterance worth of data.

func (*PocketSphinx) ProcessUtt

func (p *PocketSphinx) ProcessUtt(raw []byte, numNbest int, segment bool) ([]Result, error)

func (*PocketSphinx) StartStream

func (p *PocketSphinx) StartStream() error

StartUtt starts utterance processing.

func (*PocketSphinx) StartUtt

func (p *PocketSphinx) StartUtt() error

StartUtt starts utterance processing.

type Result

type Result struct {
	Text     string    `json:"text"`
	Score    int64     `json:"score"`
	Prob     int64     `json:"prob"`
	Segments []Segment `json:"segments"`
}

Result is a speech recognition result

type Segment

type Segment struct {
	Word       string `json:"word"`
	StartFrame int64  `json:"start_frame"`
	EndFrame   int64  `json:"end_frame"`
	Prob       int64  `json:"log_posterior_probability. "`
	AcScore    int64  `json:"acoustic_score"`
	LmScore    int64  `json:"languagemodel_score"`
	Lmbackoff  int64  `json:"languagemodel_backoff"`
}

Segment represents a word segment contains frame infomations and probabirity

func GetSegments

func GetSegments(ps *C.ps_decoder_t) []Segment

GetSegments returns word segment list for best hypotesis

func GetSegmentsForNbest

func GetSegmentsForNbest(nb *C.ps_nbest_t) []Segment

GetSegments returns word segment list for nbest_t

Jump to

Keyboard shortcuts

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