Documentation
¶
Overview ¶
Package synthesizer implements the Baidu ASR adapter for ling-base.
This adapter uses the Baidu REST short-audio recognition API. Audio bytes are accumulated locally and sent in a single POST request when SendEnd is invoked, which fits the ling-base Engine interface (non-streaming vendor).
Index ¶
- type BaiduASR
- func (b *BaiduASR) Activity() bool
- func (b *BaiduASR) ConnAndReceive(dialogID string) error
- func (b *BaiduASR) Init(tr base.ResultFunc, er base.ErrorFunc)
- func (b *BaiduASR) RestartClient()
- func (b *BaiduASR) SendAudioBytes(data []byte) error
- func (b *BaiduASR) SendEnd() error
- func (b *BaiduASR) StopConn() error
- func (b *BaiduASR) Vendor() string
- type BaiduASROption
- type BaiduASRResponse
- type Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaiduASR ¶
type BaiduASR struct {
Handler Handler
// contains filtered or unexported fields
}
BaiduASR is the Baidu short-audio ASR engine.
func NewBaiduASR ¶
func NewBaiduASR(opt BaiduASROption) *BaiduASR
NewBaiduASR builds a Baidu ASR engine from the supplied options.
func (*BaiduASR) Activity ¶
Activity returns true if the engine is initialised for an active dialog.
func (*BaiduASR) ConnAndReceive ¶
ConnAndReceive prepares the engine for a new dialog. For the REST-based flow this fetches (or refreshes) the access token and resets the audio buffer. No persistent connection is opened.
func (*BaiduASR) Init ¶
func (b *BaiduASR) Init(tr base.ResultFunc, er base.ErrorFunc)
Init registers the result and error callbacks.
func (*BaiduASR) RestartClient ¶
func (b *BaiduASR) RestartClient()
RestartClient resets the engine and re-initialises for the current dialog.
func (*BaiduASR) SendAudioBytes ¶
SendAudioBytes accumulates audio data into the local buffer. The actual recognition request is deferred until SendEnd is called.
func (*BaiduASR) SendEnd ¶
SendEnd flushes the accumulated audio to the Baidu REST API and parses the recognition result, dispatching it via the registered result callback.
type BaiduASROption ¶
type BaiduASROption struct {
APIKey string `json:"apiKey" yaml:"api_key"`
SecretKey string `json:"secretKey" yaml:"secret_key"`
AppID string `json:"appId" yaml:"app_id"`
Format string `json:"format" yaml:"format"`
Rate int `json:"rate" yaml:"rate"`
Channel int `json:"channel" yaml:"channel"`
Cuid string `json:"cuid" yaml:"cuid"`
DevPid int `json:"devPid" yaml:"dev_pid"`
ReqChanSize int `json:"reqChanSize" yaml:"req_chan_size"`
}
BaiduASROption configures the Baidu ASR engine.
func NewBaiduASROption ¶
func NewBaiduASROption(apiKey, secretKey string) BaiduASROption
NewBaiduASROption creates a default BaiduASROption.
func (*BaiduASROption) GetVendor ¶
func (opt *BaiduASROption) GetVendor() base.Vendor
GetVendor returns the vendor identifier.