Documentation
¶
Index ¶
- Constants
- func ParseWrittenResponse(serverResponseJSON string) (string, error)
- type Client
- func (c *Client) ClearConversationState()
- func (c *Client) DisableConversationState()
- func (c *Client) EnableConversationState()
- func (c *Client) GetConversationState() interface{}
- func (c *Client) SetConversationState(newState interface{})
- func (c *Client) TextSearch(textReq TextRequest) (string, error)
- func (c *Client) VoiceSearch(voiceReq VoiceRequest, partialTranscriptChan chan PartialTranscript) (string, error)
- type PartialTranscript
- type TextRequest
- type VoiceRequest
Constants ¶
const SDKUserAgent = "Go Houndify SDK"
Default user agent set by the SDK
Variables ¶
This section is empty.
Functions ¶
func ParseWrittenResponse ¶
ParseWrittenResponse will take final server response JSON (as a string) and parse out the human readable text to be displayed or spoken the end user. If the string is invalid JSON, the server had an error, or there was nothing to reply with, an error is returned.
Types ¶
type Client ¶
type Client struct { // The ClientID comes from the Houndify site. ClientID string // The ClientKey comes from the Houndify site. // Keep the key secret. ClientKey string // If Verbose is true, all data sent from the server is printed to stdout, unformatted and unparsed. // This includes partial transcripts, errors, HTTP headers details (status code, headers, etc.), and final response JSON. Verbose bool // contains filtered or unexported fields }
A Client holds the configuration and state, which is used for sending all outgoing Houndify requests and appropriately saving their responses.
func (*Client) ClearConversationState ¶
func (c *Client) ClearConversationState()
ClearConversationState removes, or "forgets", the current conversation state
func (*Client) DisableConversationState ¶
func (c *Client) DisableConversationState()
DisableConversationState disables conversation state for future queries
func (*Client) EnableConversationState ¶
func (c *Client) EnableConversationState()
EnableConversationState enables conversation state for future queries
func (*Client) GetConversationState ¶
func (c *Client) GetConversationState() interface{}
GetConversationState returns the current conversation state, useful for saving
func (*Client) SetConversationState ¶
func (c *Client) SetConversationState(newState interface{})
SetConversationState sets the conversation state, useful for resuming from a saved point
func (*Client) TextSearch ¶
func (c *Client) TextSearch(textReq TextRequest) (string, error)
TextSearch sends a text request and returns the body of the Hound server response.
An error is returned if there is a failure to create the request, failure to connect, failure to parse the response, or failure to update the conversation state (if applicable).
func (*Client) VoiceSearch ¶
func (c *Client) VoiceSearch(voiceReq VoiceRequest, partialTranscriptChan chan PartialTranscript) (string, error)
VoiceSearch sends an audio request and returns the body of the Hound server response.
The partialTranscriptChan parameter allows the caller to receive for PartialTranscripts while the Hound server is listening to the voice search. If partial transcripts are not needed, create a throwaway channel that listens and discards all the PartialTranscripts sent.
An error is returned if there is a failure to create the request, failure to connect, failure to parse the response, or failure to update the conversation state (if applicable).
type PartialTranscript ¶
type TextRequest ¶
type TextRequest struct { // The text query, e.g. "what time is it in london" Query string UserID string RequestID string RequestInfoFields map[string]interface{} }
A TextRequest holds all the information needed to make a Houndify request. Create one of these per request to send and use a Client to send it.
type VoiceRequest ¶
type VoiceRequest struct { // Stream of audio in bytes. It must already be in correct encoding. // See the Houndify docs for details. AudioStream io.Reader UserID string RequestID string RequestInfoFields map[string]interface{} }
A VoiceRequest holds all the information needed to make a Houndify request. Create one of these per request to send and use a Client to send it.