Documentation ¶
Index ¶
- Constants
- Variables
- type AllRequest
- type AllResponse
- type AsrResultCallBack
- type Client
- type Conf
- type End
- type EndResponse
- type Error
- type FakeSession
- type FakeSessionMaker
- type IResponse
- type ISession
- type ISessionMaker
- type Option
- type RecognizeResult
- type RecognizingResponse
- type SentenceEndResponse
- type SentenceStartResponse
- type Server
- type Start
- type StartConfig
- type StartResponse
- type StartResult
- type StopResponse
- type TCPResponse
- type Words
Constants ¶
View Source
const ( TCPPort = 11024 UDPPort = 11025 )
View Source
const ( StatusInit = iota StatusStart StatusEnd )
View Source
const ( CmdStart = "S" CmdEnd = "E" TypeRspStart = "RS" TypeRspEnd = "RE" TypeStop = "STOP" // 代表关闭会话 TypeSentenceStart = "SS" TypeRecognizing = "R" TypeSentenceEnd = "SE" )
View Source
const (
UDPSendLen = 1460
)
Variables ¶
View Source
var ( ErrClient = errors.New("x client error") ErrNoLooping = fmt.Errorf("%w, %s", ErrClient, "no looping read") ErrNotStart = fmt.Errorf("%w, %s", ErrClient, "status not start") ErrStartRspTimeOut = fmt.Errorf("%w, %s", ErrClient, "start response timeout") ErrEndRspTimeOut = fmt.Errorf("%w, %s", ErrClient, "end response timeout") ErrNotEnd = fmt.Errorf("%w, %s", ErrClient, "status not end") )
Functions ¶
This section is empty.
Types ¶
type AllRequest ¶
type AllRequest struct { Cmd string `json:"cmd"` Config StartConfig `json:"config,omitempty"` }
type AllResponse ¶
type AllResponse struct { Type string `json:"type"` SessionID uint32 `json:"sessionID"` TaskID string `json:"taskID"` UDPPort int32 `json:"udpPort"` Error Error `json:"error,omitempty"` Result RecognizeResult `json:"result,omitempty"` StartResult StartResult `json:"startResult,omitempty"` ConnectionClose bool `json:"connectionClose"` }
type AsrResultCallBack ¶
type AsrResultCallBack func(rsp *AllResponse) error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(agentAddr string, cb AsrResultCallBack) (*Client, error)
NewClient TODO 处理返回结果
func (*Client) Start ¶
func (c *Client) Start(conf StartConfig) error
type EndResponse ¶
type FakeSession ¶
type FakeSession struct {
// contains filtered or unexported fields
}
func (*FakeSession) CloseAll ¶
func (f *FakeSession) CloseAll()
func (*FakeSession) CommandCb ¶
func (f *FakeSession) CommandCb(allResponse *AllRequest) error
func (*FakeSession) DataCb ¶
func (f *FakeSession) DataCb(data []byte, seq uint32)
func (*FakeSession) ID ¶
func (f *FakeSession) ID() uint32
type FakeSessionMaker ¶
type FakeSessionMaker struct {
// contains filtered or unexported fields
}
func NewFakeSessionMaker ¶
func NewFakeSessionMaker() *FakeSessionMaker
func (*FakeSessionMaker) MakeSession ¶
func (f *FakeSessionMaker) MakeSession(response IResponse) (ISession, error)
type ISession ¶
type ISession interface { ID() uint32 CommandCb(allResponse *AllRequest) error DataCb(data []byte, seq uint32) CloseAll() }
type ISessionMaker ¶
type Option ¶
type Option func(s *Server)
func WithOptionSessionMaker ¶
func WithOptionSessionMaker(sm ISessionMaker) Option
type RecognizeResult ¶
type RecognizingResponse ¶
type RecognizingResponse struct { Type string `json:"type"` Result RecognizeResult `json:"result"` }
type SentenceEndResponse ¶
type SentenceEndResponse struct { Type string `json:"type"` Result RecognizeResult `json:"result"` }
type SentenceStartResponse ¶
type SentenceStartResponse struct { Type string `json:"type"` StartResult StartResult `json:"startResult"` }
type Start ¶
type Start struct { Cmd string `json:"cmd"` Config StartConfig `json:"config"` }
type StartConfig ¶
type StartResponse ¶
type StartResult ¶
type StopResponse ¶
type TCPResponse ¶
func (*TCPResponse) Close ¶
func (t *TCPResponse) Close()
Click to show internal directories.
Click to hide internal directories.