Documentation ¶
Index ¶
- Constants
- Variables
- type Context
- func (c *Context) Close() error
- func (c *Context) TextQuery(query string) (*Result, *Outcome, error)
- func (c *Context) TextQueryAsync(query string, cb func(string)) error
- func (c *Context) VoiceQueryAuto() (*Result, *Outcome, error)
- func (c *Context) VoiceQueryAutoAsync(cb func(string)) error
- func (c *Context) VoiceQueryStart() error
- func (c *Context) VoiceQueryStop() (*Result, *Outcome, error)
- func (c *Context) VoiceQueryStopAsync(cb func(string)) error
- type Outcome
- type Result
- type Verbosity
Constants ¶
const (
// DefaultDevice points to the default recording device on your machine.
DefaultDevice = "default"
)
Variables ¶
var ( // ErrInvalidResult is returned when the returned wit.ai result // does not contain a valid response. ErrInvalidResult = errors.New("invalid result") )
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds the wit context and the access token and the logic to make text and voice queries to wit.ai.
func NewContext ¶
NewContext returns a *Context given a device, access token and the level of logging verbosity.
func (*Context) Close ¶
Close closes the context that is used for relaying queries and their results back.
func (*Context) TextQuery ¶
TextQuery allows querying wit.ai service with a text query string. It returns the complete result, the first outcome or a non-nil error if one occurs.
The result is returned in a blocking manner.
func (*Context) TextQueryAsync ¶
TextQueryAsync works similar to TextQuery but is not blocking in nature. It needs callback to process the response once it arrives. If there is an error registering the callback it is returned immediately.
func (*Context) VoiceQueryAuto ¶
VoiceQueryAuto is used to query wit.ai service using voice commands via the given input device. It returns the complete result, the first outcome or a non-nil error if one occurs.
This query is run in a blocking manner.
func (*Context) VoiceQueryAutoAsync ¶
VoiceQueryAutoAsync works similar to VoiceQueryAuto but isn't blocking in nature. It registers a callback, which is called once the voice command query returns.
func (*Context) VoiceQueryStart ¶
VoiceQueryStart starts voice recording and returns immediately. The voice recording is stopped using VoiceQueryStop or VoiceQueryStopAsync command.
func (*Context) VoiceQueryStop ¶
VoiceQueryStop stops the voice recording and issues the voice query to wit.ai and blockingly waits for the response.
func (*Context) VoiceQueryStopAsync ¶
VoiceQueryStopAsync stops the voice recording and issues the voice query to wit.ai in a non-blocking manner.
type Outcome ¶
type Outcome struct { Text string `json:"_text"` Confidence float32 `json:"confidence"` Intent string `json:"intent"` }
A Outcome points to each each wit.ai outcome contained within the returned Result for a given text or voice query.
type Result ¶
type Result struct { Text string `json:"_text"` MsgID string `json:"msg_id"` Outcomes []*Outcome `json:"outcomes"` }
Result contains the wit.ai result with a list of outcomes.